首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

怎么在子类函数中调用基类函数

2012-04-26 
如何在子类函数中调用基类函数要怎么调用 我用A::get()方式调用 显示错误为the object has type qualifier

如何在子类函数中调用基类函数
要怎么调用 我用A::get()方式调用 显示错误为
the object has type qualifiers that are not compatible with the member function A::get()
这句话是什么意思 get()是double类型 而我用在子类的print()函数中 因为这个get()是virtual 在子类中有了新的定义
但是现在我只需要子类中的实现过程 要怎么调用

[解决办法]
class CBase
{
int m_base;
public:
CBase(){};
~CBase(){};

int get(){return m_base;};
};


class CTest:public CBase
{
int m_Test;
public:
CTest(){};
~CTest(){};

int get(){return m_Test;};

int CallBaseGet()
{
return CBase::get();
}
};

测试代码
CTest ff;
ff.CallBaseGet();

热点排行