Originally posted by logicalhippo
I'm beginning to agree that this interdependancy is a bad idea and I will definitely change it.
However, I am curious as to the reasons I'm getting these errors. I am using references.
Code:
class CVector2;
class CVector3
{
CVector3(const CVector2& vec) : x(vec.x), y(vec.y), z(0.0)
{ }
...
Because you are trying to access members of an undefined class. The compiler doesn't know that CVector2 has members called x and y.
You can separate them into header and source files though.
header:
Code:
class CVector2;
class CVector3
{
CVector3(const CVector2&);
...
source:
Code:
#include "CVector3.h"
#include "CVector2.h"
CVector3::CVector3(const CVector2& vec)
: x(vec.x), y(vec.y), z(0.0 {}
...