【发布时间】:2012-11-08 19:19:20
【问题描述】:
我正在尝试部分专门化非模板类的模板化成员函数:
#include <iostream>
template<class T>
class Foo {};
struct Bar {
template<class T>
int fct(T);
};
template<class FloatT>
int Bar::fct(Foo<FloatT>) {}
int main() {
Bar bar;
Foo<float> arg;
std::cout << bar.fct(arg);
}
我收到以下错误:
c.cc:14: error: prototype for ‘int Bar::fct(Foo<FloatT>)’ does not match any in class ‘Bar’
c.cc:9: error: candidate is: template<class T> int Bar::fct(T)
如何修复编译器错误?
【问题讨论】:
标签: c++ templates template-specialization partial-specialization