> I therefore include a forward reference in S of main.
This should be in the .h file
> The catch is I want to call a method in main from s and if I do this I get an error
No problem.
Try this:
1) in s.cpp: #include<main.h>
2) in main.cpp: #inlcude<s.h>
Do not try this:
1) in s.h: #include<main.h>
2) in main.h: #inlcude<s.h>
Rudy
> Class S contains a pointer to class main.
> Class main contains and instance of class S
> I therefore include a forward reference in S of main.
> The catch is I want to call a method in main from s and if I do this I get an error
> use of undefined type 'Main'.
> So how can I call a method in main from S and if I cant whats the point in being able to store a pointer to it?
JoNinty - 18 May 2004 10:01 GMT
Thank you. A well placed #include solved this
You never see this type of thing in books do you?
Matt Osborn - 18 May 2004 14:13 GMT
Large-Scale C++ Software Design by John Lakos
> Thank you. A well placed #include solved this !
> You never see this type of thing in books do you?
You can't define the function inline. The following should work
class main
class S
main* m
void foo()
}
class main
S s
int i
void S::foo()
do_something(m->i)
}