こんにちは、複数のデータ型を管理するクラスを開発しているので、さまざまな型のデータを含めることができるクラス ラッパーを作成しましたが、コンパイラの問題で立ち往生しています。
class BaseType{
public:
virtual ~BaseType(){}
virtual BaseType & clone() const =0;
};
template<typename T>
class DataType : public BaseType
{
public:
DataType(const T & aValueData = T()):mValue(aValueData) {}
BaseType & clone() const
{
return DataType<T>();
}
private:
T mValue;
};
class MValueData
{
public:
template<typename T>
MValueData(T & aAnyValue = DataType(aAnyValue)):mTypeData(aAnyValue)
{}
private:
BaseType mTypeData;
};
int main()
{
return 0;
}
このコードは、次のコンパイラ エラーを生成します。
error: cannot declare field 'MValueData::mTypeData' to be of abstract type 'BaseType'
mTypeDataメンバー変数はそれとして宣言されていますが、ベースタイプから派生しているため、エラーは表示されません。事前にThx