I have a problem regarding two classes that are dependent on eachother in their definition. What I'm trying to acomplish is the following;
A.h:
1 2 3 4 5 6 7 8 9 10 11 12
#include "B.h"
class A
{
private:
/* a bunch of functions and varibles here */
int F1();
int F2();
...
friendint B::Func(A*);
}
B.h:
1 2 3 4 5 6
class A;
class B
{
int Func(A*);
}
B.cpp:
1 2 3 4 5 6 7
#include "B.h"
int B::Func(A*)
{
return(A->F1() + A->F2())
}
The problem is that B only knows that there is a class called A, but it does not know what it contains (F1, F2 ...). I cannot use class A before it's defined. How do i get around this problem? I cannot include A.h in B.h because either way I put it, either
A.h asks: What is class B?
or
B.h asks: What is class A?
I hope I've made my problem understood, ask if clarification is needed somewhere.
AND, move any code from the header files (from one class involving the other at least) into the source files where both class definitions will be visible.
Sorry, I missed to input the include guards. They are there already. I'm coding on a computer without network access so I had to type it in manually here.
The problem was that I forgot to include the A.h file in B.cpp file, which left B.cpp without the complete A-class definition.