Login
Order Now
Support
C++ Assignment Help on Class Bus

C++ Assignment Help on Class Bus

  • 27th Jan, 2022
  • 16:17 PM
#include

using namespace std;

class Bus{
    public:
        Bus(){
            cout << "Bus Default Constructor is called!" << endl;
        }
        Bus(string busDriverName){
            //cout << "Bus driver’s name: " << busDriverName << "." << endl;
            this->name = busDriverName;
        }
        void printDriverName(){
            cout << "Driver’s name is " << name << endl;
        }
        string getDriverName(){
            return name;
        }
        void setDriverName(string busDriverName){
            this->name = busDriverName;
        }
    
    private:
        string name;
        
};

int main(){
    cout << "Hello C++! I love CS52" << endl;
    
    Bus bus1;  // Creating an object of class Bus.
    
    Bus bus2("Hathairat R");  // Creating another object of class Bus.
    
    bus2.printDriverName();
    
    bus2.setDriverName("Alex M");
    
    string name = bus2.getDriverName();
    
    bus2.printDriverName();
    
    
    return 0;
}

Share this post

assignment helpassignment helperassignment expertsassignment writing services