なぜこれらのコードをコンパイルできないのか分かりません。私はVisual C++ 2010でテストし、gccは-std = C++ 0xでテストしました。誰かが何か提案しますか?感謝! ありがとう!C++ 0x参照コラプスに関する質問
template<typename T>
class Foo
{
public:
void test(const T&){cout<<"const";}
void test( T&){cout<<"non const";}
};
int main()
{
int a;
Foo<int&> f;
}
コンパイルエラー: '無効はFoo ::テスト(T)':メンバ関数が既に定義または宣言
をしかし、これはコンパイルすることができますなぜですか?
template<typename T> void foo(const T&){cout<<"const"; }
template<typename T> void foo(T&){cout<<"non const"; }
int main()
{
int a;
foo<int&>(a);
}
i'vは、C++ 0xの記事を読んで言った:T & & == T &ので、constのT & & == constのT &?