Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Personal Information program. Does not accept address as a string [closed]
- #ifndef INFO_H
- #define INFO_H
- #include <string>
- class info
- {
- private:
- std::string name;
- std::string address;
- int age;
- std::string phone;
- public:
- void setName(std::string);
- void setAge(int);
- void setAddress(std::string);
- void setPhone(std::string);
- std::string getName();
- int getAge();
- std::string getAddress();
- std::string getPhone();
- };
- #endif
- #include "info.h"
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- void info::setName(string n)
- {
- name = n;
- }
- void info::setAge(int ag)
- {
- age = ag;
- }
- void info::setAddress(string adr)
- {
- address = adr;
- }
- void info::setPhone(string phn)
- {
- phone = phn;
- }
- string info::getName()
- {
- return name;
- }
- string info::getAddress()
- {
- return address;
- }
- int info::getAge()
- {
- return age;
- }
- string info::getPhone()
- {
- return phone;
- }
- #include <iostream>
- #include "info.h"
- #include<string>
- using namespace std;
- int main()
- {
- info MyInfo;
- string person_name;
- int person_age;
- string person_address;
- string person_phone;
- cout << "Enter name: ";
- cin >> person_name;
- MyInfo.setName(person_name);
- cout << "Enter your age: ";
- cin >> person_age;
- MyInfo.setAge(person_age);
- cout << "Enter address: ";
- cin >> person_address;
- MyInfo.setAddress(person_address);
- cout << "Enter a phone number: ";
- cin >> person_phone;
- MyInfo.setPhone(person_phone);
- cout << MyInfo.getName() << " " << MyInfo.getAge() << " " << MyInfo.getAddress() << " " << MyInfo.getPhone() << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment