[Note] no known conversion for argument 1 from 'float' to 'const Student&'
时间: 2023-07-15 11:14:03 浏览: 64
这个错误提示表明在某个函数或方法调用中,第一个参数的类型应该是 `const Student&`(即 `Student` 类型的常量引用),但实际传入的参数类型却是 `float`,两者类型不匹配。
可能的原因是你在调用函数或方法时,传入的参数类型不正确,或者是函数或方法的声明或定义与你期望的不同。你需要检查函数或方法的声明和定义,确保参数类型与实际传入的参数类型匹配。如果你是在调用库函数或第三方库的函数时遇到这个错误,那可能是你的参数类型不正确或者是你使用了错误的函数签名,你需要检查文档或其他资源来找到正确的函数签名和参数类型。
相关问题
PLCXProcess.h:80:7: note: no known conversion for argument 1 from 'std::string {aka std::basic_string<char>}' to 'char*'
这是一个编译错误的信息,指出在调用GetplcxCurDate函数时,传递给它的参数类型不匹配。具体来说,您正在尝试将std::string类型的参数传递给一个期望char*类型的函数。
要解决这个问题,您需要将std::string类型的参数转换为char*类型。您可以使用.c_str()函数将std::string转换为char*,例如:
```cpp
std::string str = "example";
char* cstr = new char[str.length() + 1];
strcpy(cstr, str.c_str());
```
然后,您可以将cstr作为参数传递给GetplcxCurDate函数。
另外,请记住在使用完cstr后释放它的内存,以避免内存泄漏。
QByteArray::fromHex(hex_str);报错form_para.cpp:342:68: No viable conversion from 'QString' to 'const QByteArray' qbytearray.h:181:5: candidate constructor not viable: no known conversion from 'QString' to 'const char *' for 1st argument qbytearray.h:189:12: candidate constructor not viable: no known conversion from 'QString' to 'QByteArray &&' for 1st argument qbytearray.h:463:12: candidate constructor not viable: no known conversion from 'QString' to 'QByteArrayDataPtr' for 1st argument qbytearray.h:524:20: candidate constructor not viable: no known conversion from 'QString' to 'const QByteArray &' for 1st argument qbytearray.h:405:67: passing argument to parameter 'hexEncoded' here
根据您提供的信息,这个错误是因为您使用了不同类型的参数。函数QByteArray::fromHex()需要一个十六进制字符串作为输入,而您传递了一个QString类型的参数,导致编译器无法将其转换为QByteArray类型。您需要将QString类型的参数转换为QByteArray类型的十六进制字符串,然后再将其传递给函数QByteArray::fromHex()。您可以使用QString的toUtf8()函数将QString转换为QByteArray类型的十六进制字符串,然后再将其传递给QByteArray::fromHex()函数。例如:
QString hex_str = "616263";
QByteArray hex_data = QByteArray::fromHex(hex_str.toUtf8());
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)