怎么在子类函数中调用基类函数
如何在子类函数中调用基类函数
要怎么调用 我用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();
要怎么调用 我用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();