模板函数无法识别
template function doesn't recognize
我有一个类
template <class T>
class BaseStrategy
{
template<typename Period, typename Rep>
void print_time(tm t, chrono::duration<Rep, Period> fraction);
}
并且实现是(在同一个 .h 文件中(
template <typename T>
template <typename Rep, typename Period >
void BaseStrategy<T>::print_time(tm t, std::chrono::duration<Rep, Period> fraction)
{
/some code/
}
但是当我编译代码时,我收到以下错误:
错误:'void BaseStrategy::p rint_time(tm, std::chrono::d uration<_Rep, _Period>(' 与类中的任何内容都不匹配 'BaseStrategy' void BaseStrategy::p rint_time(tm t, 标准::时间::d尿分数( ^~~~~~~~~~~~~~~
/home/yaodav/Desktop/git_repo/test/include/BaseStrategy.h:216:10: 错误:候选为:模板模板无效 BaseStrategy::p rint_time(tm, std::chrono::d uration( 空隙print_time(TM T,计时::d尿分数(;
为什么会发生此错误?以及如何修复它
定义中模板参数的顺序
template <typename Rep, typename Period >
void BaseStrategy<T>::print_time(tm t, std::chrono::duration<Rep, Period> fraction)
与声明中模板参数的顺序不对应
template<typename Period, typename Rep>
void print_time(tm t, chrono::duration<Rep, Period> fraction);
要么写
template<typename Rep, typename Period>
void print_time(tm t, chrono::duration<Rep, Period> fraction);
或(更令人困惑(
template<typename Period, typename Rep>
void print_time(tm t, chrono::duration<Period, Rep> fraction);
相关文章:
- 从不同的附加依赖项中识别等同命名的函数
- 静态堆栈函数不会 1) 输入第一个元素 2)添加新元素时识别旧元素
- 无法识别的类函数副本
- 函数无法识别我在C++传递节点指针向量?
- 如何识别符号表中的符号是我'application'函数
- C++ 编译错误:gnu_printf是无法识别的格式函数类型
- 函数的函数无法识别输入参数
- c++为什么ifstream get()函数返回无法识别的特殊字符
- 已定义构造函数的构造函数无法识别
- 模板函数无法识别
- C ++中的函数为什么我的编译器无法识别错误()
- 如何在 unordered_map 中使用 cpp 来识别 lambda 函数?
- 编写模式识别'函数以查找特定顺序出现的数字?C++
- 试图使用int []作为打字模板,编译器未识别函数最小的原型中的参数
- 表达式无法识别函数c++中的指针
- 引脚二进制检测:如何精确识别函数名称
- 无法识别函数定义
- 如何从头文件中快速识别函数
- AST 访问者函数调用表达式无法正确识别函数调用
- QML不能识别c++函数