I have included the proper
Header Files ,
Header Gard
but i cannot instantiate a specific class
Getting Error
error C2065: 'ClassName' : undeclared identifier
Sample Code
Class A{
//instantiate class B
}
Class B {
//need to instantiate Class A
}
Since you haven’t posted any real code for us to actually make use of, I’ll take a guess as to what your code actually looks like:
A.h:
B.h:
B.cpp:
As Flinsch said, you need to have forward declarations to avoid problems with include ordering. The simplest way is to get rid of the circular includes in the .h files and just include the forward declarations (
class B;andclass A;into A.h and B.h) instead.