Например есть такой заголовок и класс :
#ifdenf __MATRIX_H__
#define __MATRIX_H__
#include "vector.h"
namespace math
{
class Matrix
{
public:
void setRows(const Vector& v,
const Vector& v2,
const Vector& v3,
const Vector& v4);
union
{
struct {
float x1, y1, z1, w1;
float x2, y2, z2, w2;
float x3, y3, z3, w3;
float x4, y4, z4, w4;
};
float data[4][4];
};
};
inline void Matrix::setRows(const Vector& v, const Vector& v2, const Vector& v3, const Vector& v4)
{
data[0][0] = v.x;
data[0][1] = v.y;
data[0][2] = v.z;
data[0][3] = v.w;
data[1][0] = v2.x;
data[1][1] = v2.y;
data[1][2] = v2.z;
data[1][3] = v2.w;
data[2][0] = v3.x;
data[2][1] = v3.y;
data[2][2] = v3.z;
data[2][3] = v3.w;
data[3][0] = v4.x;
data[3][1] = v4.y;
data[3][2] = v4.z;
data[3][3] = v4.w;
}
}
#endif
и такой :
#ifndef __VECTOR_H__
#define __VECTOR_H__
#include "matrix.h"
namespace math
{
class Matrix;
class Vector
{
public:
Vector operator * (const Matrix& rMatrix);
};
inline Vector Vector::operator * (const Matrix& rMatrix) const
{
float x = this->x * rMatrix.data[0][0] + this->y * rMatrix.data[1][0] +
this->z * rMatrix.data[2][0] + this->w * rMatrix.data[3][0];
float y = this->x * rMatrix.data[0][1] + this->y * rMatrix.data[1][1] +
this->z * rMatrix.data[2][1] + this->w * rMatrix.data[3][1];
float z = this->x * rMatrix.data[0][2] + this->y * rMatrix.data[1][2] +
this->z * rMatrix.data[2][2] + this->w * rMatrix.data[3][2];
float w = this->x * rMatrix.data[0][3] + this->y * rMatrix.data[1][3] +
this->z * rMatrix.data[2][3] + this->w * rMatrix.data[3][3];
return Vector(x, y, x, w);
}
}
#endif
Вот основные методы из классов которые создают проблему. Как откомпилировать такой код ? Или как можно решить эту проблему ? Struct forward decl тут не поможет как я понимаю.
forward declaration.