Include headers.
-
-
Hi I have a header file x.h in this I have #include "y.h" In y.h file I want to use the class declared in x.h. But if I include x.h in y.h file, it is giving me an error saying class X is not decalred. Could anyone tell me how to solve this? Regards Neha
:wtf: :wtf: x , y , y , x , ... *uggg* put this line where you using it. class X;
MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"
-
:wtf: :wtf: x , y , y , x , ... *uggg* put this line where you using it. class X;
MSN Messenger. prakashnadar@msn.com Tip of the day of visual C++ IDE. "We use it before you do! Visual C++ was developed using Visual C++"
-
Thanks for the reply. Here is the code In X.h #include "y.h" Class X { } In Y.h #include "X.h" Class X; Class Y { X m_Item; } In this case I will get a error as 'm_Item' uses undefined class 'X' How to slove this?
Instead of using the class X, use a pointer to the class:
Class Y { X* m_Item; }
This will solve your problem because you won't have to include the X.h header in the Y.h file (you'll have to include it in the Y.cpp file instead). Hope this helps -
Thanks for the reply. Here is the code In X.h #include "y.h" Class X { } In Y.h #include "X.h" Class X; Class Y { X m_Item; } In this case I will get a error as 'm_Item' uses undefined class 'X' How to slove this?
Just remove line #include "y.h" from X.h file it should work
greatest thing is to do wot others think you cant
suhredayan@omniquad.com>messenger :suhredayan@hotmail.com