-
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?
-
Placing the line:
before the first struct should solve the problem.
Z.
-
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;
-
Oh, I didnt catch that =(.
Z.