Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class animal {
- public:
- int legs;
- int eyes;
- string name;
- animal(int l, int e, string n) {
- legs = l;
- eyes = e;
- name = n;
- }
- };
- class spider : public animal {
- public:
- string ability;
- spider(int l, int e, string n, string a):animal(l, e, n) {
- ability = a;
- }
- };
- int main() {
- spider Vlad(8, 8, "Spider_Vlad", "Web");
- cout << "My name is " << Vlad.name << endl;
- cout << "I have " << Vlad.legs << " legs and " << Vlad.eyes << " eyes." << endl;
- cout << "My special ability is " << Vlad.ability;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement