我在聲明模板類型時遇到很大困難,如下所示。`typedef typename Foo的模板聲明<T> :: Bar Bar'
#include <cstdlib>
#include <iostream>
using namespace std;
template <class T>
class Foo
{
typedef T Bar;
};
template <class T>
typedef typename Foo<T>::Bar Bar;
int main(int argc, char *argv[])
{
Bar bar;
Foo<int> foo;
system("PAUSE");
return EXIT_SUCCESS;
}
我得到錯誤
template declaration of `typedef typename Foo<T>::Bar Bar'
約行
template <class T>
typedef typename Foo<T>::Bar Bar;
我這樣做是因爲我想避免編寫類型名富::酒吧throught我的代碼。
我在做什麼錯?
謝謝!你們所有人都有同樣的幫助。我希望我能接受收到的所有三個答案。無論如何,我會投三個答案。 – geraldCelente
@geraldCelente:我不認爲這很重要,或者任何人都不高興 - 選擇你認爲最有用的答案:-)(或者投擲一枚硬幣。) –
有沒有一個庫(例如:boost)提供了一個「backaround 「對於仍然脫離C++ 11流行的編譯器(比如gcc/mingw編譯器)? –