[表示 : 全て 最新50 1-99 101- 201- 301- 401- 501- 601- 701- 801- 901- 2chのread.cgiへ]
Update time : 05/09 08:32 / Filesize : 231 KB / Number-of Response : 986
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

スレを勃てるまでもないC/C++の質問はここで 10



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が継承されてないのはなぜでしょうか?






[ 続きを読む ] / [ 携帯版 ]

全部読む 前100 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧]( ´∀`)<231KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef