C++ 两个参数模板的作用与调用中的一个参数不同

C++ 两个参数模板的作用与调用中的一个参数不同,c++,C++,对于作业(这是我一直坚持的一个相当小的部分,我没有要求任何人做作业),我们在主文件中提供了以下代码及其调用: template <class number_type> class Point { public: Point(const number_type& x_, const number_type& y_) : x(x_),y(y_) {} // REPRESENTATION number_type x; number_type y; }; t

对于作业(这是我一直坚持的一个相当小的部分,我没有要求任何人做作业),我们在主文件中提供了以下代码及其调用:

template <class number_type>
class Point {
public:
  Point(const number_type& x_, const number_type& y_) : x(x_),y(y_) {}
  // REPRESENTATION
  number_type x;
  number_type y;
};

template <class number_type, class label_type>
class QuadTree {
public:
    QuadTree(const number_type& number_, const label_type& label_) : number(number_), label(label_){}

    number_type number;
    label_type label;
    };

int main() {
std::vector< std::pair<Point<int>,char> > simple_points;

QuadTree<int,char> simple;
}
模板
类点{
公众:
点(常数数型&x,常数数型&y):x(x),y(y){
//代表
数字_类型x;
数字_类型y;
};
样板
类四叉树{
公众:
四叉树(常量编号、类型和编号、常量标签、类型和标签):编号(编号)、标签(标签){
编号\类型编号;
标签\ U型标签;
};
int main(){
std::vectorsimple_点;
简单四叉树;
}
但是,使用与提供的编码非常相似的样式会在我的终端中产生“无匹配功能”错误:

我很困惑为什么它在这种情况下不起作用,以及我能做些什么来修复它

请注意,我们不允许使用c++11、结构和其他一些工具。此外,我们不允许更改“main”函数中的任何内容,因此四叉树很简单;我们必须保持现状

main.cpp: In function ‘void simple_test()’:
main.cpp:110:22: error: no matching function for call to ‘QuadTree<int, char>::QuadTree()’
   QuadTree<int,char> simple;
                      ^
main.cpp:110:22: note: candidates are:
In file included from main.cpp:14:0:
quad_tree.h:56:5: note: QuadTree<number_type, label_type>::QuadTree(const number_type&, const label_type&) [with     number_type = int; label_type = char]
     QuadTree(const number_type& number_, const label_type& label_) : number(number_), label(label_){}
     ^
quad_tree.h:56:5: note:   candidate expects 2 arguments, 0 provided
quad_tree.h:54:7: note: QuadTree<int, char>::QuadTree(const QuadTree<int, char>&)
 class QuadTree {
       ^
quad_tree.h:54:7: note:   candidate expects 1 argument, 0 provided
main.cpp:在函数“void simple_test()”中:
main.cpp:110:22:错误:调用'QuadTree::QuadTree()'时没有匹配的函数
简单四叉树;
^
main.cpp:110:22:注:候选人为:
在main.cpp中包含的文件中:14:0:
QuadTree.h:56:5:注意:QuadTree::QuadTree(常量编号类型&,常量标签类型&)[其中编号类型=int;标签类型=char]
四叉树(常量编号、类型和编号、常量标签、类型和标签):编号(编号)、标签(标签){
^
quad_tree.h:56:5:注意:候选者需要2个参数,提供0个
四叉树.h:54:7:注:四叉树::四叉树(常量四叉树&)
类四叉树{
^
quad_tree.h:54:7:注意:候选者需要1个参数,提供0个参数

您的
四叉树
构造函数接受2个参数,但您可能(根据错误消息)有如下定义

QuadTree<int,char> simple; 
四叉树简单;
它声明的对象没有传递给构造函数的参数

QuadTree<int, char> simple(2, 'a'); // need to specify the parameters
quadtreesimple(2,'a');//需要指定参数
请注意,由于您定义了构造函数,编译器不再为您生成默认构造函数。

此代码:

QuadTree<int,char> simple;
所以你必须做:

QuadTree<int, char> simple(42, 'C');
quadtreesimple(42,'C');

请包含一个和一个完整的错误消息。@NickL,因为在你回复之前,你从未尝试过做类似于
点p;
的事情,我也尝试过,得到了相同的结果。即使受到不允许更改主要内容的限制,我也能明白我只需要删除我的构造函数。
QuadTree<int, char> simple(42, 'C');