- 783 名前:デフォルトの名無しさん mailto:sage [2005/08/06(土) 02:36:31 ]
- 次のようなコードが、Visual C++では通るけどGCCでは通りません。
オブジェクトの名前と番号の型を保持する構造体を用意 template<class S,class I> struct Types { typedef S String; typedef I Integer; }; この定義を受け取って型を定義するベースクラスを作成 template<class T> struct Base { typedef typename T::String StringType; typedef typename T::Integer IntegerType; }; そして、これを利用するサブクラスを作成。 template<class T> struct Derived : public Base<T> { StringType name; //!< ここでコンパイルエラー IntegerType number; //!< 同様 }; typedef Types<std::string,int> StdTypes; Derived<StdTypes> derived;
|

|