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.

Recommended Answers

All 2 Replies

That snippet cannot work because, in func the compiler is unable to handle tap->par1. The details of class B are unknown at this point.
The header file will compile, but the cpp file will need another include which contains the class definition for B.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.