错误:无法将函数定义与现有声明匹配
error:unable to match function definition to an existing declaration
我遇到了问题,无法解决。当我编译时,我的所有函数都遇到了问题,我在这里举了一个例子。错误为 C2244:无法将函数定义与现有声明匹配。这是我的头文件。
template <typename T>
class Gestionnaire {
public:
Gestionnaire();
~Gestionnaire();
bool addElement(const T* element);
bool removeElement(const T* element);
template < typename P>
bool removeContent(P& predicat);
template < typename P>
T* findElement(P& predicat) const;
bool findElement(const T& element) const;
private:
std::list<T*> liste_;
};
template<typename P>
template <typename T>
bool Gestionnaire<T>::removeContent(P& predicat) {
std::remove_if(liste_begin(), liste_.end(), predicat);
}
您必须将template<typename P>
和template <typename T>
切换为与声明中显示的顺序相同的顺序。模板参数的第一个列表用于类模板,第二个列表用于模板化成员函数:
template<typename T>
template<typename P>
bool Gestionnaire<T>::removeContent(P& predicat) {
std::remove_if(liste_begin(), liste_.end(), predicat);
}
相关文章:
- 如何在C++中声明/定义相互依赖的模板?
- C++概念是否允许我的类在声明/定义中指定它满足某些概念?
- MSVC:无法识别的模板声明/定义(使用 Clang/GCC 编译)
- 我可以重用同一个模板来声明/定义多个东西吗(而不复制模板代码)
- C++-模板类中模板函数的单独声明/定义
- 在C 中使用继承时,请避免使用未缴纳的函数声明/定义
- C++模板能否确定所声明/定义的实例是否为常量
- 如何在程序中声明/定义一次并在两个类中使用映射列表
- LBNF,C函数声明/定义,减少冲突
- 声明/定义返回具有自动返回类型的 valarray 的函数时的隔离错误
- #用{}和声明定义混淆
- CTOR 声明/定义中接受的 const 限定符(LLVM 错误?)
- C++ 从一个源文件中声明/定义的变量从另一个源文件访问另一个源文件
- 无法识别的模板声明/定义
- 只在.cpp中声明/定义静态方法可以吗
- 声明/定义自定义类定制对象的正确方法
- typedef声明定义未命名类时链接失败
- 用visual c++实现COM对象的声明/定义和实例化
- VS 2012中的显式模板声明/定义
- 命名空间内的友元函数声明/定义