私はC++の名前デアンゲリングコードのテストケースをいくつか書いていますが、これをコンパイルしようとすると奇妙なエラーが発生します:(以下は病理学的に悪いC++コードです。C++テンプレートの質問
"typetest.cpp", line 165: error: nontype "Oog<T, U>::Huh<F>::Wham [with F=T]"
is not a template
任意のアイデアを、私は修正することができますどのように次のように
template<class U, class V>
class TStruct
{
U u;
V v;
public:
void setU(const U& newu) {u = newu; }
};
template<class T, class U>
class Oog
{
T t;
U u;
public:
Oog(const T& _t, const U& _u) : t(_t), u(_u) {}
void doit(TStruct<T,U> ts1, TStruct<U,T> ts2, U u1, T t1) {}
template<class F>
class Huh
{
F f;
public:
template<class V>
class Wham
{
V v;
public:
Wham(const V& _v) : v(_v) {}
void joy(TStruct<T,V> ts1, U u, F f) {}
};
};
int chakka(const Huh<T>::Wham<U>& wu, T t) {} // error here
};
誤差はありますか?
ありがとうございます!私は 'typename'について知っていましたが、そのような方法で' template'キーワードを使わなければならないという考えはありませんでした。 –
+1:別の良い答え!今週は少なくとも2回です! :D –
@Tomalak、あなたは「良い答え」のコメントをして、誰かがそれに反対した後であなたの投票/コメントを取り戻す! – iammilind