/ Published in: C++
Basic usage of class and objects
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> // Basic program to show the usage of class and objects // Vamsi using namespace std; class person { char name[30]; int age; public : void getdata(void); void putdata(void); }; void person :: getdata(void){ cout << "Please Enter The Name \n"; cin >> name; cout << "Please Enter The Age \n"; cin >> age; } void person :: putdata(void){ cout << "Name Is :" << name << "\n"; cout << name << "'s Age Is " << age << "\n"; } int main () { person a; a.getdata(); a.putdata(); person b; b.getdata(); b.putdata(); return 0; }