【发布时间】:2013-09-09 14:51:21
【问题描述】:
我有一个基类:
class Base
{
public:
functions...
private:
std::vector<float> privateElement;
}
还有一个派生的:
class Derived : public Base
{
public:
functions...
Derived(anotherElement) : privateElement(anotherElement)
{
}
}
我现在的问题是每次我尝试构建我的项目时,编译器(gcc 4.7.2)总是抱怨无法访问privateElement,比如:
class Derived does not have any field named privateElement
std::vector<float> Base::privateElement is private
有人可以帮我吗?
【问题讨论】:
-
然后呢?这就是
private的设计目的?!?
标签: c++ inheritance private public derived-class