Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Person
- {
- private:
- char name[20];
- int age;
- public:
- char* get_name()
- {
- return name;
- }
- int get_age(int a)
- {
- return age;
- }
- };
- Person new_person();
- int main()
- {
- Person new_Person;
- new_Person = new_person();
- cout << "The person's name is " << new_Person.name << " and that person is " << new_Person.age << " years old." << endl;
- return 0;
- }
- Person new_person()
- {
- Person person;
- char* name_holder;
- int value;
- cout << "What is the person's name?" << endl;
- cin.getline(name_holder,20);
- person.get_name() = name_holder;
- cout << "What is the person's age?" << endl;
- cin >> value;
- person.get_age() = value;
- return person;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement