C++继承有点类似于c语言 结构体套用
#include <iostream>
#include <string>
using namespace std;
//基类,父类
class Vehicle{
public:
string type;
string contry;
string color;
double price;
int numOfWheel;
void run();
void stop();
};
//派生类,子类
class Roadster:public Vehicle{
public:
void openTopped();
void pdrifting();
};
int main()
{
Roadster paoche;
paoche.type = "保时捷";
cout<< paoche.type<<endl;
return 0;
}