34 3 C:\Users\19088\Desktop\xx\yu\课程设计\版本2.cpp [Note] candidate expects 4 arguments, 0 provided
时间: 2023-09-18 15:13:34 浏览: 39
这个问题与麦田怪圈与投票合约的内容无关,而是一个关于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); // 创建矩形对象
```
这样就可以避免上述错误。
form_para.cpp:336:30: Call to member function 'arg' is ambiguous qstring.h:313:31: candidate function qstring.h:315:31: candidate function qstring.h:1111:25: candidate function qstring.h:1113:25: candidate function qstring.h:1115:25: candidate function qstring.h:1117:25: candidate function qstring.h:1119:25: candidate function qstring.h:1121:25: candidate function
这个错误提示是因为在调用`arg()`函数时,编译器无法确定应该调用哪个函数。在QT中,`arg()`函数有多个重载形式,如果在调用时没有传递足够的参数信息,编译器就无法确定应该调用哪个函数。
为了解决这个问题,可以显式地指定要调用的`arg()`函数的重载形式,如下所示:
```cpp
int num = -255; // 负数
QString hex_str;
if (num >= 0) {
hex_str = QString("%1").arg(num, 8, 16, QChar('0'));
} else {
hex_str = QString("%1").arg(((1 << 32) - 1) ^ ((-num - 1) << 1) | 1, 8, 16, QChar('0'));
}
qDebug() << hex_str;
```
在调用`arg()`函数时,将要调用的重载形式显式地指定为`arg(int, int, int, QChar)`,这样编译器就能够确定要调用哪个函数了。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.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)