In template: no matching member function for call to 'insert'
时间: 2023-09-23 10:05:12 浏览: 523
这个错误通常是因为你在使用insert函数时,参数类型不匹配。insert函数的参数类型应该符合容器的要求。
例如,如果你使用的是std::set容器,insert函数的参数应该是容器元素的类型。如果你使用的是std::map容器,insert函数的参数应该是一个std::pair对象,表示键值对。
请确保你在调用insert函数时传递了正确的参数类型,并且与容器的要求相匹配。如果仍然遇到问题,请提供更多的代码和错误信息,以便我可以帮助你更好地解决问题。
相关问题
no matching function for call to 'Ticker::Ticker(void (&)(), int)'
This error message typically indicates that there is no constructor defined for the Ticker class that takes a function pointer as an argument.
To fix this error, you need to define a constructor for the Ticker class that takes a function pointer as an argument. Here's an example:
```
class Ticker {
public:
Ticker(void (*function)()): _function(function) {}
void tick() {
_function();
}
private:
void (*_function)();
};
```
In this example, the Ticker class takes a function pointer as an argument to its constructor. The function pointer is then stored as a member variable, and can be called by the tick method.
With this constructor defined, you should be able to create a Ticker object and pass in a function pointer as an argument without encountering the "no matching function for call" error.
阅读全文