ヘッダー内にこのコードがあります(編集済み):
template <int i> class A {};
template <> class A <1> { B<1> _b; };
template <int i> class B : public A <i> {};
template <> class B <1> : public A <1> {};
そして、どういうわけか次のように使用します:
#include "template_A_B.h"
int main ()
{
A<1> a;
B<1> b;
return 0;
}
明らかに、コンパイルエラーが発生します:
error: ‘B’ does not name a type
B の前方宣言を追加すると
template <int i> class B;
私は得る
error: field ‘_b’ has incomplete type
コンパイル時。
また、 A を前方宣言し、クラス定義の順序を切り替えて、次を取得しようとしました。
error: declaration of ‘struct A<1>’