// const修饰的成员虚函数,能否在子类中重写?请举例说明 // 可以 #include using namespace std; class A { public: virtual void show() const { cout << "A" << endl; } }; class B : public A { public: virtual void show() const override { cout << "B" << endl; } }; int main() { A *p = new B; p->show(); // B B *q = new B; q->show(); // B return 0; }