单选题:根据下列类模板声明,正确初始化对象的方式是( )
根据下列类模板声明,正确初始化对象的方式是( )
c++
template<typename T1, typename T2>
class MyClass{
private:
T1 x;
T2 y;
public:
MyClass(T1 _x, T2 _y):x(_x),y(_y){}
};
A.c++
MyClass<int,char> a(10,'a');
B.c++
MyClass a(10,'a');
C.c++
MyClass<int,char> a;
D.c++
MyClass a;
answer:A
c++
template<typename T1, typename T2>
class MyClass{
private:
T1 x;
T2 y;
public:
MyClass(T1 _x, T2 _y):x(_x),y(_y){}
};
A.c++
MyClass<int,char> a(10,'a');
B.c++
MyClass a(10,'a');
C.c++
MyClass<int,char> a;
D.c++
MyClass a;
answer:A