// ========================================================================== // $Id: amphibus.cpp,v 1.2 2010/12/06 15:34:10 jlang Exp $ // CSI2372 example Code for lecture 14 // ========================================================================== // (C)opyright: // // Jochen Lang // SITE, University of Ottawa // 800 King Edward Ave. // Ottawa, On., K1N 6N5 // Canada. // http://www.site.uottawa.ca // // Creator: jlang (Jochen Lang) // Email: jlang@site.uottawa.ca // ========================================================================== // $Log: amphibus.cpp,v $ // Revision 1.2 2010/12/06 15:34:10 jlang // Added comments // // Revision 1.1 2006/11/26 16:42:34 jlang // added amphibus // // // ========================================================================== #include using std::cout; using std::endl; /** * Boat with no parent */ class Boat { float d_displacement; public: Boat( float _displacement = 0.0 ); ~Boat(); }; /** * Bus with no parent */ class Bus { int d_noPassengers; public: Bus( int _noPassengers = 0 ); ~Bus(); }; /** * AmphiBus with two parents */ class AmphiBus : public Boat, public Bus { int d_tChange; public: AmphiBus(int _tChange, int _noPassengers, float _displacement ); ~AmphiBus(); }; //------------------------------------------------------ // Functions -- just report construction and destruction //------------------------------------------------------ Boat::Boat( float _displacement ) : d_displacement( _displacement ) { cout << "Boat::Boat( " << _displacement << " )" << endl; } Boat::~Boat() { cout << "Boat::Boat() " << endl; } Bus::Bus( int _noPassengers ) : d_noPassengers( _noPassengers ) { cout << "Bus::Bus( " << _noPassengers << " )" << endl; } Bus::~Bus() { cout << "Bus::Bus()" << endl; } AmphiBus::AmphiBus(int _tChange, int _noPassengers, float _displacement ) : Boat( _displacement ), Bus( _noPassengers ), d_tChange( _tChange ) { cout << "AmphiBus::AmphiBus( " << _tChange << ", " << _noPassengers << ", " << _displacement << " )" << endl; } AmphiBus::~AmphiBus() { cout << "AmphiBus::~AmphiBus() " << endl; } /** * Construct and destruct an amphibus */ int main() { AmphiBus ab( 60, 32, 7.5 ); return 0; }