|
-
Mar 15th, 2002, 05:02 PM
#1
Thread Starter
Addicted Member
Forward Declaration
I have 2 structures that contain each other..
Code:
typedef struct tagUSER {
long lName
GROUP group
const char *lpszPass
}; USER
typdef struct tagGROUP {
long lID
USER user
}; GROUP
It doesnt work. Is there a way to forward the declaration for the
structures so they can see each other?
Always looking for a better and faster way!
-
Mar 15th, 2002, 11:02 PM
#2
Placing the line:
before the first struct should solve the problem.
Z.
-
Mar 17th, 2002, 10:37 AM
#3
It does not and it's good that way. Two structs that contain each other (or one that contains itself) would actually need infinite memory.
If you need something like this, keep a pointer to a struct of the other type, but don't create access violations 
Then you still need a forward declaration like Zaei showed.
And the alternative names for your structs must come before the semicolon:
} GROUP;
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Mar 17th, 2002, 11:14 PM
#4
Oh, I didnt catch that =(.
Z.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|