次のものがあるとします(単純化されたケース):
class Color;
class IColor
{
public:
virtual Color getValue(const float u, const float v) const = 0;
};
class Color : public IColor
{
public:
float r,g,b;
Color(float ar, float ag, float ab) : r(ar), g(ag), b(ab) {}
Color getValue(const float u, const float v) const
{
return Color(r, g, b)
}
}
class Material
{
private:
IColor* _color;
public:
Material();
Material(const Material& m);
}
さて、Material のコピー コンストラクターで抽象的な IColor のディープ コピーを行う方法はありますか? つまり、IColor へのポインタだけでなく、m._color (カラー、テクスチャ) の値をコピーする必要があります。