I am creating a header-only library. In this library I would like to already use a class that is defined later in the header. For example:
class A {
public:
int i;
A(int x) : i(x) {};
B func(B inp) {
B out(i*inp.j);
return out;
};
};
class B {
public:
int j;
B(int x) : j(x) {};
A other(A inp) {
A out(j*inp.i);
return out;
};
};
Naturally my compiler does not like this. It produces the first error on the line on which func
is defined:
error: unknown type name 'B'
Is there a way to overcome this?