I cannot post any of my actual code due to the fact I am working with PS3 Dev kits and the source code is not allowed to be released publicly, so I will try my best to explain my problem without using any of the PS3 specific code.
Say I have 2 header file (A.h and B.h) along with 2 matching cpp files (A.cpp and B.cpp)
A.h looks similar to this
#ifndef A_H
#define A_H
#include "B.h"
class A
{
public:
void function1();
void functionA();
B m_b;
};
#endif
While B.h looks like this
#ifndef B_H
#define B_H
#include "A.h"
class B
{
public:
void function2();
void functionB();
A m_a;
};
#endif
Both these classes have other functions the the corresponding cpp files are required to used but I have left out. Within A.cpp I need to use all the functions from A.h and a single function from B.h and within B.cpp I need to use all the functions from B.h and a single function from A.h
So A.cpp currently looks similar to this:
#include A.h
#include B.h
void function1()
{
code;
}
void functionA()
{
code;
m_b.function2();
}
and B.cpp looks like
#include A.h
#include B.h
void function2()
{
code;
}
void functionB()
{
code;
m_a.function1();
}
Now obviously there is a lot more code than this but this is where I am getting the problem when compiling. I get the compiler error "Error 2 error 20: identifier "A" is undefined" and the matching "Error 2 error 20: identifier "B" is undefined". Why?