Advertisement
andruhovski

prog-0302c

Feb 20th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. // prog-0302c.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7. class Vehicle
  8. {
  9. public:
  10.     double speed;
  11.     double fuel;
  12.     Vehicle();
  13.     ~Vehicle();
  14. };
  15.  
  16. Vehicle::Vehicle():speed(0)
  17. {
  18.     cout << "Vehicle" << endl;
  19. }
  20.  
  21. Vehicle::~Vehicle()
  22. {
  23. }
  24.  
  25. class Automobile: virtual public Vehicle { 
  26. public:
  27.     Automobile() { cout << "Automobile" << endl; };
  28.     void move_ground() { cout << "Move ground" << endl; };
  29. };
  30.  
  31. class Ship : virtual public Vehicle {
  32.     double tonnage;
  33. public:
  34.     Ship() { cout << "Ship" << endl; };
  35.     void move_sea() { cout << "Move sea" << endl; };
  36. };
  37.  
  38. class Amphibie : public Automobile, public Ship
  39. {
  40. public:
  41.     Amphibie() { cout << "Amphibie" << endl; };
  42.     void print_data()
  43.     {
  44.         cout << speed << endl;
  45.     }
  46. };
  47.  
  48. int _tmain(int argc, _TCHAR* argv[])
  49. {
  50.     Amphibie *a= new Amphibie();
  51.     a->print_data();
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement