fork download
  1. #include <iostream>
  2. using namespace std;
  3. class person
  4. {
  5. char name[30];
  6. int age;
  7. public:
  8. void getdata(void);
  9. void display(void);
  10. };
  11. void person :: getdata(void)
  12. {
  13. cout<<"Enter Name: ";
  14. cin>>name;
  15. cout<<"Enter Age: ";
  16. cin>>age;
  17. }
  18. void person :: display(void)
  19. {
  20. cout<<"\nName: "<<name;
  21. cout<<"\nAge: "<<age;
  22. }
  23. int main()
  24. {
  25. person p;
  26. p.getdata();
  27. p.display();
  28. return 0;
  29. }
Success #stdin #stdout 0s 5272KB
stdin
Nisen
22
stdout
Enter Name: Enter Age: 
Name: Nisen
Age: 22