【发布时间】:2017-04-29 01:02:40
【问题描述】:
我不明白模板的所有继承..
template <typename T>
class Mere
{
protected:
Mere();
};
class Fille2 : public Mere<int>
{
protected:
Fille2(){
Mere();
}
};
int main(int argc, char** argv) {
return 0;
}
为什么会出现这个错误?
main.cpp:22:5: error: 'Mere<T>::Mere() [with T = int]' is protected
Mere();
当我把“Mere()”公之于众时,一切正常吗?我的班级“Mere”不能有“受保护”的功能吗?为什么?
【问题讨论】:
-
这不是你在 c++ 中调用父类的构造函数的方式...请参阅here 了解如何完成
标签: c++ templates inheritance visibility