kvarnerexpress 0 Report post Posted June 10, 2005 Or will it create a circular include problem? What do you do if you need them to, and forward class declarations won't work?Forward class declarations only allow you to declare an instance of that class, but you can't access member functions, you have to include the header file. So if you use MS Visual C++ .NET and the code is placed in the header files, then what is the solution? I have two classes(forms) that need to include each other but it's not working. When I try it it stops recognizing the classes and gives errors like, "missing storage-class or type sepcifiers"I've also used about every combination of #ifndef, #define, #endif combo's I could think of. It's driving me crazy!Thanks for any help I might possibly get. Share this post Link to post Share on other sites
fffanatics 0 Report post Posted June 10, 2005 No circular classes do not include the header files in each other's header. Instead, in the main or whatever part of the program uses the class that includes another class, you would include both files. Then in the two class files you just would have class Class1; Class2 {...}; and then in the second class you would do class Class2; Class1 {...}; Let me know if this makes sense becuase if not i will include an example that i have used in a class of mine last semester. Just PM or post a reply Share this post Link to post Share on other sites
switch 0 Report post Posted June 30, 2005 just my two cents worth, but maybe you should take the stuff you need for both classes out of their respective header files and put them in a single header file. sort of like a kind of factorisation. for example: //class1.hclass myFirstClass{ //functions, variables etc}//class2.hclass mySecondClass{ //more functions variables etc} becomes //myClasses.hclass myFirstClass {...};class mySecondClass {...}; then, if myFirstClass needs to reference mySecondClass, i think you can add this line above the myFirstClass definition: class mySecondClass; hope this works / helps. good luck. oh and just out of curiousity, if you wouldn't mind posting that example fffantics, i had a bit of trouble understanding your last post but it seems like its good stuff. thanks! Share this post Link to post Share on other sites