码迷,mamicode.com
首页 > 编程语言 > 详细

c++ 继承多个类

时间:2015-06-18 21:54:27      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
using namespace std;

class BaseA {
public:
    void say() {
        cout << "hello world" << endl;
    }
};

class BaseB {
public:
    void eat() {
        cout << " eating watermelon" << endl;
    }
};


class Human : public BaseA, public BaseB {
public:
    void dance(){
        cout << " dancing " << endl;
    }
};


int main(){
    Human man;
    man.eat();
    man.say();
    man.dance();

    return 0;
}
技术分享

 

c++ 继承多个类

标签:

原文地址:http://www.cnblogs.com/i80386/p/4587065.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!