I have a Base class
class Keyframebase
{
private:
std::string stdstrName;
float time;
KeyframeType keyframeType;
public:
Keyframebase();
Keyframebase(KeyframeType keyType);
Keyframebase(const Keyframebase &key);
Keyframebase& operator = (const Keyframebase &key);
std::string getName();
};
Which is derived by Another class.
class SumKeyframeXYZ : public Keyframebase
{
private:
float x;
float y;
float z;
public:
SumKeyframeXYZ();
SumKeyframeXYZ(float x, float y, float z);
SumKeyframeXYZ(const SumKeyframeXYZ& key);
// const Sum_Position& operator=(const Container& container);
SumKeyframeXYZ& operator=(const SumKeyframeXYZ& key);
void setValue(float x, float y, float z);
};
This is the copy constructor for the Derived class.
SumKeyframeXYZ::SumKeyframeXYZ(const SumKeyframeXYZ& key) : Keyframebase(
key )
{
this->x = key.x;
this->y = key.y;
this->z = key.z;
}
Since i want to copy the Base class members also when i copy Object of derived class so is this the correct approach of giving a derived class object as argument to base class.
this->x = key.x
etc and replace it with a proper member initialisation idiom: Keyframebase(key), x(key.x)
etc`. – Jacksmelt