无法在main中调用子类函数

时间:2019-12-24 10:18:49

标签: c++ oop inheritance

#include <iostream>
using namespace std;

class vehicle{
    public:
        void fuel(){
            cout<<" this is fuel amount\n";
        }
        void capacity(){
            cout<<"this is capacity\n";
        }
        void breaks(){
            cout<<"the  breaks works fine\n";
        }
};

class bus: public vehicle{

    void g(){
        cout<<"this is bus\n";
    }

};

int main ()
{

bus wagernar;


wagernar.breaks();

cout<<endl;

wagernar.capacity();

cout<<endl;

wagernar.fuel();

cout<<endl;


}

0 个答案:

没有答案