ランダム クラス タイプ T と整数の 2 つのコンポーネントを取るクラスを作成し、次のように実装します。
template <class A, int B>class Test { // two components,
private:
A first;
int second;
public:
Test();
Test (A,int);
}
Test.cpp では、次のことを行いました。
template <class T,int i> Test<T,i>::Test() {}
template <class A,int i>Test<A,i>::Test(T a, int b):first(a) {second=b;}
しかし、メイン関数では:
Test<int, int > T1; //It can not be passed
Test<int, 4> T2; //It can not be passed
int x = 8;
Test<int, x> T3 (3,4);// can not be passed
上記のジェネリック クラスからオブジェクト インスタンスを宣言するにはどうすればよいですか?