Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // prog-0302c.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- class Vehicle
- {
- public:
- double speed;
- double fuel;
- Vehicle();
- ~Vehicle();
- };
- Vehicle::Vehicle():speed(0)
- {
- cout << "Vehicle" << endl;
- }
- Vehicle::~Vehicle()
- {
- }
- class Automobile: virtual public Vehicle {
- public:
- Automobile() { cout << "Automobile" << endl; };
- void move_ground() { cout << "Move ground" << endl; };
- };
- class Ship : virtual public Vehicle {
- double tonnage;
- public:
- Ship() { cout << "Ship" << endl; };
- void move_sea() { cout << "Move sea" << endl; };
- };
- class Amphibie : public Automobile, public Ship
- {
- public:
- Amphibie() { cout << "Amphibie" << endl; };
- void print_data()
- {
- cout << speed << endl;
- }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- Amphibie *a= new Amphibie();
- a->print_data();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement