Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : VIRTUAL1.CPP

 
Output of file : VIRTUAL1.CPP contained in archive : CPPTUT.ZIP
// Chapter 10 - Program 1
#include

class vehicle {
int wheels;
float weight;
public:
void message(void) { cout << "Vehicle message\n";}
};


class car : public vehicle {
int passenger_load;
public:
void message(void) { cout << "Car message\n";}
};


class truck : public vehicle {
int passenger_load;
float payload;
public:
int passengers(void) {return passenger_load;}
};


class boat : public vehicle {
int passenger_load;
public:
int passengers(void) {return passenger_load;}
void message(void) { cout << "Boat message\n";}
};


main()
{
vehicle unicycle;
car sedan;
truck semi;
boat sailboat;

unicycle.message();
sedan.message();
semi.message();
sailboat.message();
}



// Result of execution
//
// Vehicle message
// Car message
// Vehicle message
// Boat message


  3 Responses to “Category : C++ Source Code
Archive   : CPPTUT.ZIP
Filename : VIRTUAL1.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/