#include <iostream>
#include <type_traits>
using namespace std;
class MakeCar {
public:
void makefun() {
makecarhead();
makecarbody();
makecartail();
}
virtual void makecarhead() = 0;
virtual void makecarbody() = 0;
virtual void makecartail() = 0;
public:
MakeCar() {
std::cout << "MakeCar" << std::endl;
}
virtual ~MakeCar() {
std::cout << "~MakeCar" << std::endl;
}
};
class makeBus : public MakeCar {
public:
void makecarhead()
{
std::cout << "makecarhead" << std::endl;
}
void makecarbody()
{
std::cout << "makecarbody" << std::endl;
}
void makecartail()
{
std::cout << "makecartail" << std::endl;
}
public:
makeBus() {
std::cout << "makeBus" << std::endl;
}
virtual ~makeBus() {
std::cout << "~makeBus" << std::endl;
}
};
int main()
{
MakeCar* p = new makeBus();
p->makefun();
delete p;
return 0;
}
步骤比较固定,具体的几个步骤里面的具体操作交由子类去完成。
|