Click here to Skip to main content
15,885,048 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Nested structs problem Pin
manchukuo13-Feb-11 10:58
manchukuo13-Feb-11 10:58 
GeneralRe: Nested structs problem Pin
Richard MacCutchan13-Feb-11 11:40
mveRichard MacCutchan13-Feb-11 11:40 
AnswerRe: Nested structs problem Pin
Luc Pattyn13-Feb-11 11:05
sitebuilderLuc Pattyn13-Feb-11 11:05 
GeneralRe: Nested structs problem Pin
manchukuo13-Feb-11 11:08
manchukuo13-Feb-11 11:08 
AnswerRe: Nested structs problem Pin
Luc Pattyn13-Feb-11 11:11
sitebuilderLuc Pattyn13-Feb-11 11:11 
AnswerRe: Nested structs problem Pin
Niklas L13-Feb-11 11:24
Niklas L13-Feb-11 11:24 
GeneralRe: Nested structs problem Pin
Richard MacCutchan13-Feb-11 11:41
mveRichard MacCutchan13-Feb-11 11:41 
GeneralRe: Nested structs problem [modified] Pin
Niklas L13-Feb-11 11:52
Niklas L13-Feb-11 11:52 
The following is perfectly legal
struct A;
struct B;

struct A
{
  int lolipops;
  B* candy;

  A(B* ptr);

  void action(int pass);
};

struct B{
 int gums;
 A* candy;
 
 B(A* ptr);

 void action(int pass);
};


The compiler needs to know the size of a class when it's compiling it. That's the major reason why things must be declared in advance. In this case, the dependency size is known since the member is a pointer to the forward declared class. You can of course not use that pointer until the thing it points to has been properly declared, and that's the problem in the OP.

Edit: When I answered, the members were actually pointers to the other class. That might have changed since your reply?

GeneralRe: Nested structs problem Pin
manchukuo13-Feb-11 12:39
manchukuo13-Feb-11 12:39 
GeneralRe: Nested structs problem Pin
Richard MacCutchan13-Feb-11 13:33
mveRichard MacCutchan13-Feb-11 13:33 
GeneralRe: Nested structs problem Pin
manchukuo13-Feb-11 15:13
manchukuo13-Feb-11 15:13 
GeneralRe: Nested structs problem Pin
Niklas L13-Feb-11 21:04
Niklas L13-Feb-11 21:04 
GeneralRe: Nested structs problem Pin
manchukuo14-Feb-11 12:44
manchukuo14-Feb-11 12:44 
GeneralRe: Nested structs problem Pin
Stefan_Lang14-Feb-11 0:19
Stefan_Lang14-Feb-11 0:19 
GeneralRe: Nested structs problem Pin
manchukuo14-Feb-11 12:48
manchukuo14-Feb-11 12:48 
GeneralRe: Nested structs problem Pin
Richard MacCutchan13-Feb-11 13:28
mveRichard MacCutchan13-Feb-11 13:28 
GeneralRe: Nested structs problem Pin
Niklas L13-Feb-11 19:44
Niklas L13-Feb-11 19:44 
Questionhow to init member class array if the class has no default constrctor? Pin
includeh1013-Feb-11 5:16
includeh1013-Feb-11 5:16 
AnswerRe: how to init member class array if the class has no default constrctor? Pin
Iain Clarke, Warrior Programmer13-Feb-11 6:34
Iain Clarke, Warrior Programmer13-Feb-11 6:34 
AnswerRe: how to init member class array if the class has no default constrctor? Pin
jschell13-Feb-11 8:00
jschell13-Feb-11 8:00 
AnswerRe: how to init member class array if the class has no default constrctor? Pin
CPallini13-Feb-11 21:40
mveCPallini13-Feb-11 21:40 
AnswerRe: how to init member class array if the class has no default constrctor? Pin
Stefan_Lang13-Feb-11 23:19
Stefan_Lang13-Feb-11 23:19 
QuestionMFC: Use firefox in MFC Pin
msn9212-Feb-11 22:39
msn9212-Feb-11 22:39 
AnswerRe: MFC: Use firefox in MFC Pin
wangningyu12-Feb-11 22:47
wangningyu12-Feb-11 22:47 
AnswerRe: MFC: Use firefox in MFC Pin
Andrew Brock12-Feb-11 23:41
Andrew Brock12-Feb-11 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.