Advertisement
boyan16-z

Rocket

May 17th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. class planer{
  9. private:
  10.  
  11. public:
  12.     char model[30];
  13.     char konstr[30];
  14.     int year;
  15.  
  16.     planer(char *b_model, char *b_konstr, int year){
  17.         strcpy(model,b_model);
  18.         strcpy(konstr, b_konstr);
  19.         this->year = year;
  20.     }
  21.  
  22.  
  23. };
  24.  
  25. class plane : public planer{
  26. private:
  27.  
  28. public:
  29.     int speed;
  30.     int km;
  31.     plane(char *model, char *konstr, int year, int speed, int km) : planer(model, konstr, year) {
  32.         this->speed = speed;
  33.         this->km = km;
  34.     }
  35.  
  36.     void print_plane(){
  37.         cout << "Model: " << this->model << endl;
  38.         cout << "Konstructor: " << this->konstr << endl;
  39.         cout << "Year: " << this->year << endl;
  40.         cout << "Speed: " << this->speed << endl;
  41.         cout << "Km: " << this->km << endl;
  42.     }
  43. };
  44.  
  45. class rocket : public plane{
  46. public:
  47.     char special[30];
  48.     char fuel[30];
  49.  
  50.     rocket(char *model, char *konstr, int year, int speed, int km, char *b_special, char *b_fuel) : plane(model, konstr, year, speed, km) {
  51.         strcpy(special, b_special);
  52.         strcpy(fuel, b_fuel);
  53.     }
  54.  
  55.     void print_all(){
  56.         this->print_plane();
  57.         cout << "Special: " << this->special << endl;
  58.         cout << "Fuel: " << this->fuel << endl;
  59.     }
  60. };
  61.  
  62. int main() {
  63.  
  64.     auto bit = rocket("Bit", "Li", 2000, 1000, 320, "War", "Disel");
  65.     bit.print_all();
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement