C++ Class Inheritance Deriving One Class from Another
#include <iostream> using namespace std; class Vehicle// w w w . ja v a 2 s .c o m { public: int count; void Drive() { cout << "Driving, driving, driving..." << endl; } }; class Toyota : public Vehicle { public: void MeAndMyToyota() { cout << "Just me and my Toyota!" << endl; } }; int main() { Toyota MyCar; MyCar.MeAndMyToyota(); MyCar.Drive(); return 0; }