Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Animal {
- public:
- string name;
- float weight;
- float age;
- };
- class Dog : public Animal {
- public:
- Dog(string _name, float _weight, float _age) {
- name = _name;
- weight = _weight;
- age = _age;
- }
- void bark() {
- cout << name << " barked!" << endl << endl;
- }
- void about() {
- cout <<
- "Name: " << name << endl <<
- "Age: " << age << " years" << endl <<
- "Weight: " << weight << " pounds" << endl << endl;
- }
- };
- int main() {
- Dog fred("Fred", 100, 7);
- fred.bark();
- fred.about();
- }
Advertisement
Add Comment
Please, Sign In to add comment