c++ 继承多个类 及虚函数

#include <iostream>
using namespace std;

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

class BaseB {
public:
    virtual 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;
}



 

posted on 2015-06-18 21:14  雨渐渐  阅读(8544)  评论(0编辑  收藏  举报

导航