I defined a class A and a class B like following:
class A
{
public:
using Type = int;
B::Type v;
};
class B
{
public:
using Type = double;
A::Type v;
};
And then I get a compile error
error: 'B' does not name a type
The following codes don't work, either.
class B;
class A
{
public:
friend class B; // makes no sense
using Type = int;
B::Type v;
};
class B
{
public:
using Type = double;
A::Type v;
};
You know, a class cannot be defined twice, so A must be defined after B, or B must be defined after A.
How can I use each other's member types?
Methods can be defined outside, but can member types be defined outside a class?
My only solution is to move the types out of the classes.