https://www.cnblogs.com/tianzeng/p/9775672.html
https://blog.csdn.net/warpar/article/details/73466672
重写覆盖demo:
#include "iostream"
using namespace std;
class Base
{
public:
virtual void test(int a)
{
cout<<"this is base there are different parameters with virtual"<<endl;//main to achieve override
}
};
class Ship:public Base
{
public:
void test()
{
cout<<"this ia ship there are different parameters with virtual cover"<<endl;
}
};
int main()
{
//call the ship object
Ship s;
s.test();
return 0;
}
子类继承父类不实现覆盖
#include "iostream"
using namespace std;
class Animal
{
public:
Animal(int height,int weight)
{
cout<<"animal construct"<<endl;
}
};
class Fish:public Animal
{
public:
Fish():Animal(400,300)
{
cout<<"fish construct"<<endl;
}
};
int main()
{
//call the ship object
Fish fh;
return 0;