Forward declaration Doubt

majesticmanish's Avatar, Join Date: Dec 2008
Newbie Member
I have a doubt regarding forwarding declaration.

in .h file:
class B;
class A{
void func(B* tap);
}

in .cpp file
void A::func(B* tap){
tmpo=tap->par1;
}

does the above code snipet correct if not whats the problem. Please be descriptive.
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
In .cpp file I assume you have included the .h file and if that is true its correct but then tmpo and other variables are in doubt
Mridula's Avatar, Join Date: Mar 2008
Pro contributor
You need have to include the .h file for declaration for class A in the file where "class B" declaration is there.
Apart from that tempo is what here?
majesticmanish's Avatar, Join Date: Dec 2008
Newbie Member
I got my doubt clear. I have to include B.h file in A.cpp file as earlier i was in a doubt since i already had made forward declaration of B in A's header file.

tempo is nothing imp. here....just a part of rough-code.

btw, thanks 4 clearing my doubt.