C++ 使用参数化构造函数的主函数中的模板

C++ 使用参数化构造函数的主函数中的模板,c++,C++,我已经创建了以下类的模板 template <class T,int MAX_SIZE> class XYZ{ public: XYZ(); // default constructor, construct an empty heap XYZ(T* items, int size);// construct a heap from an array of elements 我想复制数组中项目的值 < C++中构造函数应该调用什么?我正在尝试这样。 int a[1

我已经创建了以下类的模板

template <class T,int MAX_SIZE>
class XYZ{
public:

    XYZ(); // default constructor, construct an empty heap
    XYZ(T* items, int size);// construct a heap from an array of elements
我想复制数组中项目的值

< C++中构造函数应该调用什么?我正在尝试这样。

int a[10]={32,31,.............};
PQueue<int[] ,10> q0;

默认调用应该是:根据上面的签名

XYZ<int,10> var;
参数ctor调用应该如下所示:假设[10]存在并且在范围内

 XYZ<int,10> var{a,10};

至于将值复制到var,则取决于取决于您的ctor的实现。

您能否根据需要为我们提供一个ctor?在C++98中,“q0”必须由构造函数初始化,而不是由“{…}”初始化。我已经完成了以下操作。int a0[4]={39,40,67,78};XYZ q1{a0,4};您的编译器是旧的。因此使用XYZ q1a0,4;还要注意这意味着int a0[4]
 XYZ<int,10> var{a,10};