candidate expects 0 arguments,1 provided
时间: 2024-05-23 10:11:23 浏览: 9
这个错误信息通常出现在函数调用时传入的参数数量与函数定义时所期望的参数数量不一致时。例如,如果一个函数定义为不需要参数,但在调用时传入了一个参数,就会出现这个错误。
要解决这个问题,你需要检查函数定义和函数调用的代码,并确保两者的参数数量相同。如果你不确定该函数需要哪些参数,可以查看函数的文档或者查看函数实现的代码。
相关问题
34 3 C:\Users\19088\Desktop\xx\yu\课程设计\版本2.cpp [Note] candidate expects 4 arguments, 0 provided
这个问题与麦田怪圈与投票合约的内容无关,而是一个关于C++编程的问题。根据提供的引用内容,这是一个关于文件"C:\Users\19088\Desktop\xx\yu\课程设计\版本2.cpp"中的错误信息。根据错误信息,代码文件中的第34行的函数"candidate"需要4个参数,但是没有提供任何参数。因此,编译器产生了这个错误。请检查代码文件中第34行的函数调用,确保提供了正确的参数。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
你给出的上面的代码有这样的错误main.cpp: In constructor 'Rect::Rect(Point, Point)': main.cpp:20:32: error: no matching function for call to 'Point::Point()' Rect(Point tl_, Point br_) { ^ main.cpp:20:32: note: candidates are: main.cpp:11:5: note: Point::Point(int, int) Point(int x_, int y_) { ^ main.cpp:11:5: note: candidate expects 2 arguments, 0 provided main.cpp:8:7: note: constexpr Point::Point(const Point&) class Point { ^ main.cpp:8:7: note: candidate expects 1 argument, 0 provided main.cpp:8:7: note: constexpr Point::Point(Point&&) main.cpp:8:7: note: candidate expects 1 argument, 0 provided main.cpp:20:32: error: no matching function for call to 'Point::Point()' Rect(Point tl_, Point br_) { ^ main.cpp:20:32: note: candidates are: main.cpp:11:5: note: Point::Point(int, int) Point(int x_, int y_) { ^ main.cpp:11:5: note: candidate expects 2 arguments, 0 provided main.cpp:8:7: note: constexpr Point::Point(const Point&) class Point { ^ main.cpp:8:7: note: candidate expects 1 argument, 0 provided main.cpp:8:7: note: constexpr Point::Point(Point&&) main.cpp:8:7: note: candidate expects 1 argument, 0 provided 详细评判结果 »
这个错误是因为在 Rect 类的构造函数中调用了 Point 类的构造函数,但是没有提供任何参数。根据错误信息,Point 类有三个候选构造函数,但是都需要至少一个参数。
你需要在创建 Rect 对象时为 Point 对象提供所需的参数。例如:
```
Point tl(0, 0); // 创建左上角点
Point br(10, 10); // 创建右下角点
Rect rect(tl, br); // 创建矩形对象
```
这样就可以避免上述错误。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![xlsx](https://img-home.csdnimg.cn/images/20210720083732.png)