Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Person
  7. {
  8. private:
  9. char name[20];
  10. int age;
  11.  
  12. public:
  13. char* get_name()
  14. {
  15. return name;
  16. }
  17.  
  18. int get_age(int a)
  19. {
  20. return age;
  21.  
  22. }
  23. };
  24.  
  25. Person new_person();
  26.  
  27. int main()
  28. {
  29. Person new_Person;
  30. new_Person = new_person();
  31. cout << "The person's name is " << new_Person.name << " and that person is " << new_Person.age << " years old." << endl;
  32. return 0;
  33. }
  34.  
  35. Person new_person()
  36. {
  37. Person person;
  38. char* name_holder;
  39. int value;
  40.  
  41. cout << "What is the person's name?" << endl;
  42. cin.getline(name_holder,20);
  43. person.get_name() = name_holder;
  44.  
  45. cout << "What is the person's age?" << endl;
  46. cin >> value;
  47. person.get_age() = value;
  48.  
  49. return person;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement