delorie.com/archives/browse.cgi | search |
From: | Matthew Heyman <kay DOT heyman AT airmail DOT net> |
Newsgroups: | comp.os.msdos.djgpp,comp.graphics.algorithms |
Subject: | Re: struct problem... structs within struct |
Date: | Tue, 10 Aug 1999 21:57:40 +0000 |
Organization: | Airnews.net! at Internet America |
Lines: | 49 |
Message-ID: | <B3E5A4C3ADD224F8.495357A5D48014CA.32C448311127B040@lp.airnews.net> |
X-Orig-Message-ID: | <37B0A054 DOT 6AFD AT airmail DOT net> |
References: | <A7083B60FEDED7E0 DOT 7F2CBC07CD9B5AB8 DOT 019CE2E485CE12C4 AT lp DOT airnews DOT net> <37AF5947 DOT 66951F05 AT NOSPAMthepentagon DOT com> <8432818566957DB4 DOT DF5776918DB4D437 DOT AD3715803EC19E27 AT lp DOT airnews DOT net> <37B0847D DOT 60A75CAB AT NOSPAMthepentagon DOT com> <615620E39BE81788 DOT CF8A6B1990FBBD97 DOT C41A8FB435290DCC AT lp DOT airnews DOT net> <37B16FAE DOT 79807BE8 AT flash DOT net> |
Abuse-Reports-To: | abuse at airmail.net to report improper postings |
NNTP-Proxy-Relay: | library2.airnews.net |
NNTP-Posting-Time: | Tue Aug 10 21:58:00 1999 |
NNTP-Posting-Host: | !ajq41k-WcT=YI? (Encoded at Airnews!) |
Mime-Version: | 1.0 |
X-Mailer: | Mozilla 3.01C-KIT (Win95; U) |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Matt McLelland wrote: > > Matthew Heyman wrote: > > > All right.... digging through my code and came up with a possible > > realization. In several instinces I use structs within structs. Is > > this possible? Consider the following piece of code... > > > > typedef struct > > { > > int x; > > }point; > > > > typedef struct > > { > > point loc; > > }vert; > > > > point p1; > > p1 = 2; > > I assume you meant p1.x=2 here, > > > vert v1; > > v1 = p1; > > and v1.pointloc = p1 here. > > > //and to access the final point within the vert > > cout <<v1.loc.x<<endl; > > > > Is my logic messed up? Can I even do this in? > > This is the second time you have posted code snippets which contain code > to be executed outside of function scope. You can't put lines like a=b > outside of a function. You can initialize a variable with a value, but > that must be done on the line in which the variable is declared. In just assumption, I assumed you realized I put everything except the struct definitions in a function. After I learned I couldn't assign values out of a function, I fixed that problem. In all truth, my problem most likely lies with a problem in the way I have assigned values throughout my various structs. The important question within the previous code snippet was the possibility of using assigning structs within structs. I'm sorry if I didn't make it clear that the code snippet was in a function. Matthew Heyman
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |