一个月学习C++笔记(七)

来源:互联网 发布:淘宝网店网页制作 编辑:程序博客网 时间:2024/05/17 22:16
C++ 继承
C++允许为一个派生类指定多个基类,这样的继承结构称作多重继承
#include <iostream>using namespace std;class Vehicle{public:Vehicle(int weight=0){Vehicle::weight=weight;}void SetWeight(int weight){cout<<"chong xin she zhi zhong liang"<<endl;Vehicle::weight=weight;}virtual void ShowMe()=0;protected:int weight;};class Car{public:Car(int weight=0,int aird=0):Vehicle(weight){Car::aird=aird;}~Car();/* data */};



0 0
原创粉丝点击