C++ > Beginners Lab Assignments
Class for storing a Person's details
Class for storing a Person's details # include
# include
// for strcpy # include
class person { char name[20]; int yob; //Year of birth int yod; // Year of death public: person() { strcpy(name,"N.A."); yob=2000; yod=2000; } ~person() { delete []name; } void getdata() { cout<<" Enter the name : "; cin.getline(name,19); cout<<" Enter the year of birth"; cin>>yob; cout<<" Enter the year of death"; cin>>yod; } void print() { cout<<" Name:"<
C++ Codes
Algorithms
Beginners
Code Snippets
Graphics
Data Structures
Games
Mathematics
Miscellaneous