Advertisement
Guest User

11_Task_1

a guest
Nov 20th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class animal {
  6.     public:
  7.         int legs;
  8.         int eyes;
  9.         string name;
  10.         animal(int l, int e, string n) {
  11.             legs = l;
  12.             eyes = e;
  13.             name = n;
  14.         }
  15. };
  16.  
  17. class spider : public animal {
  18.     public:
  19.         string ability;
  20.         spider(int l, int e, string n, string a):animal(l, e, n) {
  21.             ability = a;
  22.         }
  23. };
  24. int main() {
  25.     spider Vlad(8, 8, "Spider_Vlad", "Web");
  26.     cout << "My name is " << Vlad.name << endl;
  27.     cout << "I have " << Vlad.legs << " legs and " << Vlad.eyes << " eyes." << endl;
  28.     cout << "My special ability is " << Vlad.ability;  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement