#include <iostream>
using namespace std;
class Animal
{
private:
string name;
int age;
float weight;
public:
void set_name(string name)
{
this->name=name;
}
void set_age(int age)
{
this->age=age;
}
void set_w(float weight)
{
this->weight=weight;
}
string get_name()
{
return name;
}
int get_age()
{
return age;
}
float get_weight()
{
return weight;
}
void display()
{
cout<<this->name<<endl;
cout<<this->age<<endl;
cout<<this->weight<<endl;
}
};
class Dog:public Animal
{
private:
string breed;
public:
void set_breed(string breed)
{
this->breed=breed;
}
string get_breed()
{
return breed;
}
void display()
{
Animal::display();
cout<<this->breed<<endl;
}
};
int main()
{
Dog d1;
string name;
int age;
float weight;
string breed;
cout<<"enter name"<<endl;
cin>>name;
d1.set_name(name);
cout<<"enter age"<<endl;
cin>>age;
d1.set_age(age);
cout<<"enter weight"<<endl;
cin>>weight;
d1.set_w(weight);
cout<<"enter breed"<<endl;
cin>>breed;
d1.set_breed(breed);
cout<<"attributes after inheritanc is"<<endl;
d1.display();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjbGFzcyBBbmltYWwKewpwcml2YXRlOgoKICAgIHN0cmluZyBuYW1lOwogICAgaW50IGFnZTsKICAgIGZsb2F0IHdlaWdodDsKcHVibGljOgogICAgdm9pZCBzZXRfbmFtZShzdHJpbmcgbmFtZSkKICAgIHsKICAgICAgICB0aGlzLT5uYW1lPW5hbWU7CiAgICB9CiAgICB2b2lkIHNldF9hZ2UoaW50IGFnZSkKICAgIHsKICAgICAgICB0aGlzLT5hZ2U9YWdlOwogICAgfQogICAgdm9pZCBzZXRfdyhmbG9hdCB3ZWlnaHQpCiAgICB7CiAgICAgICAgdGhpcy0+d2VpZ2h0PXdlaWdodDsKICAgIH0KICAgIHN0cmluZyBnZXRfbmFtZSgpCiAgICB7CiAgICAgICAgcmV0dXJuIG5hbWU7CiAgICB9CiAgICAgaW50IGdldF9hZ2UoKQogICAgewogICAgICAgIHJldHVybiBhZ2U7CiAgICB9CiAgICBmbG9h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