【发布时间】:2015-04-21 13:47:28
【问题描述】:
使用 C++ 并尝试编写一个返回 thing 类型实体的方法,该实体在其父类中定义为受保护,但出现以下错误:
'thing' does not name a type
class A {
protected:
struct thing{
};
};
class B : public A {
thing getThing();
};
thing B::getThing(){ // Error occurs on this line
return new thing;
}
我怎样才能做到这一点?
【问题讨论】:
-
B::thing B::getThing() {...}
标签: c++ oop inheritance struct protected