no matching function for call to 'Person::Person(Person*)'
时间: 2023-06-20 12:03:29 浏览: 153
这个错误通常是因为你在创建 `Person` 对象时,传入了一个指向 `Person` 类型的指针,而 `Person` 类并没有一个接受指针参数的构造函数。
你可以尝试修改代码,将传入指针的部分改为传入对象本身,例如:
```
Person person1; // 创建一个 Person 对象
Person person2(&person1); // 错误:没有接受指针参数的构造函数
Person person3(person1); // 正确:使用拷贝构造函数
```
如果你需要使用指针,可以在 `Person` 类中添加一个接受指针参数的构造函数,例如:
```
class Person {
public:
Person() {}
Person(Person* p) {
// 使用指针 p 进行初始化
}
};
```
注意,在使用指针进行初始化时,需要注意指针是否为 `null`,以及需要进行合适的内存管理,避免引发内存泄漏等问题。
相关问题
no matching function for call to widget::connect
This error message typically occurs in Qt when you try to connect a signal to a slot, but the arguments of the signal and the slot do not match. To fix it, you need to make sure that the arguments of the signal and the slot are compatible.
For example, if you have a signal that takes an integer parameter and a slot that takes a string parameter, you will get this error message. To fix it, you either need to change the signal to take a string parameter or change the slot to take an integer parameter.
Here's an example of how to connect a signal to a slot with compatible arguments:
```
QObject::connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue);
```
In this example, the signal "valueChanged" takes an integer parameter and the slot "updateValue" also takes an integer parameter, so they are compatible. If your code is still giving you the "no matching function for call to widget::connect" error message, double-check the arguments of the signal and the slot to make sure they match.
报错no matching function for call to std::bind
这个错误通常是因为您使用了错误的参数类型或数量来调用std::bind()函数。std::bind()函数的参数应该是一个可调用对象和一些参数,用于绑定该可调用对象的参数。如果您的参数不匹配,编译器将无法找到匹配的函数,并报告“no matching function for call to std::bind”错误。
要解决这个问题,您应该检查您的std::bind()函数调用,并确保它们使用正确的参数类型和数量。如果您仍然无法解决问题,请考虑使用其他函数或方法来实现您的需求。