Hey.
To pytanie z cyklu, gdzie jest błąd :). Nie mogę zrozumieć co zrobiłem nie tak.
Więc klase vector3d przygotowalem już wcześniej, testowałem jej insterface i oczywiście inicializowałem używając jej wszystkich wersji konstruktora.
Wziąłem się teraz do pisania kolizji z użyciem tej klasy. Tu kompilator g++ mówi że vector3d to nie typ przy każdej próbie użycia. A co ja się pytam? Tu przykład:
./pre-compiled/collision_structures.hh:24:2: error: ‘vector3d’ does not name a type
vector3d Get_point(int x){return plane::p[x]};
Więc nie mogę znaleźć przyczyny. Poniżej podaję źródła plików
collision_structures.hh:
#ifndef _COLLISION_STRUCTURES_HH_
#define _COLLISION_STRUCTURES_HH_
#include "vector3d.hh"
//SPHARE STRUCTURE CLASS:
class sphare{
private:
float r;
vector3d center;
public:
sphare();
sphare(const vector3d& vec, float rad);
};
//PLANE STRUCTURE CLASS:
class plane{
private:
vector3d p[4];
vector3d normal;
public:
plane(vector3d n, vector3d a, vector3d b, vector3d c, vector3d d);
vector3d Get_normal(){return plane::normal};
vector3d Get_point(int x){return plane::p[x]};
};
#endif
vector3d.hh:
/* -- Part of 3D Shooter Onlin --
This file provides 3D vector object */
#ifndef _VECTOR3D_HH_
#define _VECTOR3D_HH_
#include <iostream>
#include <cmath>
#include "collision_structures.hh"
class vector3d{
private:
float x,y,z;
public:
//vector constructor initialization
vector3d();
vector3d(float a, float b);
vector3d(float a, float b, float c);
float dotProduct(const vector3d& vec2);
vector3d crossProduct(const vector3d& vec2);
float length();
void normalize();
//change vectors position
void change(float a, float b, float c);
void change(vector3d& vec2);
void change(vector3d vec2);
void ChangeX(float a);
void ChangeY(float a);
void ChangeZ(float a);
//overvrite mathematical operators to use them with vectors
vector3d operator+(const vector3d& vec2);
vector3d operator-(const vector3d& vec2);
vector3d operator*(float num);
vector3d operator/(float num);
vector3d& operator+=(const vector3d& vec2);
vector3d& operator-=(const vector3d& vec2);
vector3d& operator*=(float num);
vector3d& operator/=(float num);
bool operator==(const vector3d vec2);
bool operator!=(const vector3d vec2);
friend std::ostream& operator<<(std::ostream&
out, const vector3d& vec);
};
#endif
Dzieki, Daniel.