Use of Class in a C++ program



      #include       class person       {       char name[30];       int age;       public:       void getdata(void);       void display(void);       };       void person::getdata(void)       {       cout<<"Enter name:";       cin>>Name;       cout<<"Enter age";       cin>>Age;       }       void person::display(void)       {       cout<<"Name:";       cout<<"Age:";       }       int main()       {       person p;       p.getdata();       p.display();       return 0;       }

      OUTPUT:
         Enter name:Judson
         Enter age:27   
   
      Name:Judson       Age :27

No comments:

Post a Comment