- 582 名前:デフォルトの名無しさん mailto:sage [2009/06/02(火) 14:51:25 ]
- >cat test.cpp
#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が継承されてないのはなぜでしょうか?
|

|