c++, 为什么显示的是c2, 不报错

#include
#include
#include
using namespace std;

class c1
{
public:
c1() {
cout << "c1 构造函数" << endl;
}
virtual void function() = 0;
virtual ~c1() {
cout << "c1 析构函数" << endl;
}
};

class c2:public c1
{
public:
c2() {
cout << "c2 构造函数" << endl;
}
void function()
{
cout << "我是c2" << endl;
}
virtual ~c2() {
cout << "c2 析构函数" << endl;
}
};

class c3:public c2
{
public:
c3(){
cout << "c3 构造函数" << endl;
}
//void function()
//{
// cout << "我是c3" << endl;
//}
virtual ~c3(){
cout << "c3 析构函数" << endl;
}
};
int main(void)
{
cout << "构造函数" << endl;
cout << "***********************" << endl;
c1 *p = new c3;

cout << "调用的函数" << endl;
p->function();
cout << endl;
cout << "析构函数" << endl;
delete[] p;
system("pause");
return 0;

}

 virtual void function() = 0;  // function()是纯虚函数,在子类中必须重新定义functioin函数。

c2继承自c1,并重新定义了function函数。
c3继承自c2,function()函数也继承下来了。

因此:

 p->function(); //调用c2中function()函数,输出"我是c2"。

如果把c3类中function函数的注释去掉,刚c3类中function函数会覆盖父类c2的function函数,
这里再运行程序就会输出:"我是c3"

用心回答每个问题,如果对您有帮助,请采纳答案好吗,谢谢!