Hello
I am new to the concept of inheritance. So I have a straight forward error I think.
I want to use a protected variable from the base class. But I get an error.
Is there somebody who could tell me how to do it right and wy this doesnt work?
Thank you
Code:
class Vector {
public:
Vector(int size);
void Write(void);
void Set(int index, double value);
private:
int length;
protected:
double *array;
};
class SpaceVector: public Vector{
public:
SpaceVector();
void Set(double x, double y, double z);
SpaceVector Cross(SpaceVector &sv2);
};
SpaceVector Cross(SpaceVector &sv2){
SpaceVector sv3 = SpaceVector();
double x, y, z;
x = sv2.array[1];
return sv3;
}
Vector.h: In function ‘SpaceVector Cross(SpaceVector&)’:
Vector.h:19: error: ‘double* Vector::array’ is protected