Code:
class Vector2_1
{
protected:
double a, b;
public:
Vector2_1() {a=0; b=0;}
Vector2_1(double vec1, double vec2):a(vec1), b(vec2) {}
void SetSpecificValue(double value, int pos);
double GetSpecificValue(int pos) const;
virtual void print() {cout<<endl<<"["<<a<<" "<<b<<"]T"<<endl;}
Vector1_2 transpose() {return Vector1_2(a,b);} //the problem
Vector2_1 operator / (const double& C);
};
class Vector1_2:public Vector2_1
{
public:
Vector1_2() {Vector2_1();}
//Vector1_2(double vec1, double vec2) {Vector2_1(vec1,vec2);}
Vector1_2(double vec1, double vec2) {a=vec1; b=vec2;}
Vector1_2 operator * (const Matrix2_2&) const;
void print() {cout<<endl<<"["<<a<<" "<<b<<"]"<<endl;}
Vector2_1 transpose() {return Vector2_1(a,b);}
};
error C2501: 'Vector2_1::Vector1_2' : missing storage-class or type specifiers
error C2146: syntax error : missing ';' before identifier 'transpose'
error C2146: syntax error : missing ';' before identifier 'transpose'
error C2501: 'Vector2_1::Vector1_2' : missing storage-class or type specifiers
I have a function in the base class that generates an instance of the derived class. I assume that the problem is that the base class doesn't know the derived class because it is beneath it, therefore, I tried to declare the classes at the head of the header
Code:
class Vector2_1;
class Matrix2_2;
class Vector1_2:class Vector2_1;
This results in a massive amount of errors.