【发布时间】:2011-05-30 05:48:07
【问题描述】:
我应该通过什么方式访问这个父方法和父变量?
class Base
{
public:
std::string mWords;
Base() { mWords = "blahblahblah" }
};
class Foundation
{
public:
Write( std::string text )
{
std::cout << text;
}
};
class Child : public Base, public Foundation
{
DoSomething()
{
this->Write( this->mWords );
// or
Foundation::Write( Base::mWords );
}
};
谢谢。
编辑:如果有歧义怎么办?
【问题讨论】:
标签: c++ inheritance parent-child base-class