template 继承编译不通过
anel 2019-07-20 05:54:48 //B.h
template <int MAX>
class B {
int buf[MAX];
public:
B();
};
//B.cpp
#include "B.h"
template <int MAX>
B<MAX>::B() {
}
//C.h
#include "B.h"
class C : public B<3>{
public:
C();
};
//C.cpp
#include "C.h"
C::C():B<3>() {
}
//编译错误:undefined reference to `B<3>::B()'
//如果把模板去掉则可以通过编译,请问大神,难道c++的编译器偷懒了吗?