我正在学习C++而且我遇到过这个,我不明白这个小东西.为什么GetName()函数是字符类型的指针,为什么它是常量?
class Derived: public Base
{
public:
Derived(int nValue)
: Base(nValue)
{
}
const char* GetName() { return "Derived"; }
int GetValueDoubled() { return m_nValue * 2; }
};
Run Code Online (Sandbox Code Playgroud)