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