スレを勃てるまでもないC/C++の質問はここで 10
■ このスレッドは過去ログ倉庫に格納されています
0582デフォルトの名無しさん
2009/06/02(火) 14:51:25#include <iostream>
template <typename _T>
struct base { typedef size_t size_type; };
#ifdef CANNOTCOMPILE
template <typename _E>
struct A:base< A<_E> >{
#else
struct A:base< A >{
#endif
size_type s;
};
#ifdef CANNOTCOMPILE
typedef A<int> type;
#else
typedef A type;
#endif
int main(void)
{
type a;
a.s = 10;
return 0;
}
>g++ test.cpp
>g++ test.cpp -DCANNOTCOMPILE
test.cpp:10: error: ‘size_type’ does not name a type
test.cpp:10: note: (perhaps ‘typename base<A<_E> >::size_type’ was intended)
test.cpp: In function ‘int main()’:
test.cpp:20: error: ‘struct type’ has no member named ‘s’
頭がこんがらがってよくわからなくなってしまったのですが、
テンプレート版でsize_typeが継承されてないのはなぜでしょうか?
■ このスレッドは過去ログ倉庫に格納されています