I'm trying to create two classes and access information between the two. This should illustrate the problem that im facing.
main.cpp
#include <iostream>
#include "A.h"
#include "B.h"
int main()
{
A a = A();
B b = B();
a.setB(&b);
b.setA(&a);
return 0;
}
A.h
#include "B.h"
struct B;
struct A
{
B* b;
int fps = 60;
A() {}
void setB(B* _b) {
b = _b;
std::cout << b->var;
}
};
B.h
#include "A.h"
struct A;
struct B
{
A* a;
int var = 5;
B() {}
void setA(A* _a) {
a = _a;
std::cout << a->fps;
}
};
The error I'm getting is: C2027 use of undefined type "A"