Navigation Bar

Program of Animal class using OOP



#include<iostream>
#include<conio.h>
using namespace std;
class animal
{
                public :
                                char name[30],color[30],sex[40];
                                int age;
                                void show()
                                {
                                                cout<<"Animal Name = "<<name<<endl;
                                                cout<<"Color ="<<color<<endl;
                                                cout<<"Age= "<<age<<endl;
                                                cout<<"Sex = "<<sex<<endl<<endl;
                                }
                void eat()
                {
                                cout<<"Animal is Eating"<<endl;
                }
                void run()
                {
                                cout<<"Animal is Running"<<endl;
                }
                void sleep()
                {
                                cout<<"Animal is Sleeping"<<endl;
                }
                void input();
};
void animal::input() //Resolution operator Method
{
                cout<<"Enter a animal Name: ";
                gets(name);
                cout<<"Enter its Color: ";
                gets(color);
                cout<<"Enter sex: ";
                gets(sex);
                cout<<"Enter age: ";
                cin>>age;
}
int main()
{
                animal a;
                a.input();
                a.show();
                a.sleep();
                a.run();
                a.eat();
                return 0;
}

Output

No comments:

Post a Comment