码:
template<class T>
struct A {
void f1() {};
void f2() {};
};
template<>
struct A<int> {
void f2() {};
};
int main() {
A<int> data;
data.f1();
data.f2();
};
Run Code Online (Sandbox Code Playgroud)
test.cpp: In function 'int main()':
test.cpp:16: error: 'struct A<int>' has no member named 'f1'
Run Code Online (Sandbox Code Playgroud)
基本上,我只想专门化一个函数并使用其他函数的通用定义.(在实际代码中,我有许多我不想专门研究的函数).
这该怎么做?谢谢!
c++ templates partial-specialization template-specialization