单选题:根据下列类模板声明,正确初始化对象的方式是( )
根据下列类模板声明,正确初始化对象的方式是( )
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,string> a(10,"abc");
B.c++
MyClass a(10,"abc");
C.c++
MyClass<int,string> 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,string> a(10,"abc");
B.c++
MyClass a(10,"abc");
C.c++
MyClass<int,string> a;
D.c++
MyClass a;
answer:A