Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <limits>
  4.  
  5. using namespace std;
  6.  
  7. class personalData {
  8.     private:
  9.         string name;
  10.         string address;
  11.         int age;
  12.         string phone;
  13.  
  14.     public:
  15.         void setName(string newName);
  16.         void setAddress(string newAddress);
  17.         void setAge(int newAge);
  18.         void setPhone(int newphone);
  19.         string fetchName();
  20.         string fetchAddress();
  21.         int fetchAge();
  22.   string fetchphone();
  23.         void input();
  24. };
  25.  
  26.  
  27.     void personalData::setName(string newName) {
  28.         name = newName;
  29.     }
  30.  
  31.     void personalData::setAddress(string newAddress) {
  32.         address = newAddress;
  33.     }
  34.  
  35.     void personalData::setAge(int newAge) {
  36.         age = newAge;
  37.     }
  38.  
  39.     void personalData::setPhone(int newphone) {
  40.         phone = newphone;
  41.     }
  42.  
  43.     string personalData::fetchName() {
  44.         return name;
  45.     }
  46.  
  47.     string personalData::fetchAddress() {
  48.         return address;
  49.     }
  50.  
  51.     int personalData::fetchAge() {
  52.         return age;
  53.     }
  54.  
  55.     string personalData::fetchphone() {
  56.         return phone;
  57.     }
  58.  
  59.     void personalData::input() {
  60.         cout << "Name: ";
  61.         cin >> name;
  62.         cout << "Address: ";
  63.         cin >> address;
  64.         cout << "Age: ";
  65.         cin >> age;
  66.   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
  67.         cout << "Phone: ";
  68.         cin >> phone;
  69.     }
  70.  
  71.     int main() {
  72.         personalData you;
  73.         personalData friend1;
  74.         personalData friend2;
  75.         cout << endl << "Enter your personal information below." << endl;
  76.         you.input();
  77.         cout << endl;
  78.         cout << "Enter your first friends' personal information below." << endl;
  79.         friend1.input();
  80.         cout << endl;
  81.         cout << "Enter your second friend's personal information below." << endl;
  82.         friend2.input();
  83.         cout << endl;
  84.         return 0;
  85.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement