1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include <iostream>
#include <sstream>
using namespace std;
class Person
{
protected:
string name,
address,
phone,
email; //variables for Student, Faculty, and Staff
public:
virtual string str() const {};
Person() {};
Person(string, string, string, string) {};
};
class Student:public Person
{
protected:
string status;
public:
string str() const {
stringstream sso;
sso << "Name: " << name << endl
<< "Status: " << status << endl
<< "Address: " << address << endl
<< "Phone Number: " << phone << endl
<< "Email: " << email << endl;
return sso.str();
}
Student() {};
Student(string, string, string, string, string) {};
};
int main()
{
string s;
string tmp_office;
double tmp_salary;
Person *p1;
cout << "Enter the account type: ";
getline(cin, s);
if ( s == "Student")
{
string tmp_name, tmp_address, tmp_phone, tmp_email;
cout << "Enter the person's name: ";
getline(cin, tmp_name);
cout << "Enter the person's address: ";
getline(cin, tmp_address);
cout << "Enter the person's phone: ";
getline(cin, tmp_phone);
cout << "Enter the person's email: ";
getline(cin, tmp_email);
if ( s == "Student" ) //STUDENT OPTION***
{
string tmp_status;
cout << "Enter the student's status: ";
getline(cin, tmp_status);
p1 = new Student(tmp_status, tmp_name, tmp_address, tmp_phone, tmp_email); //5 student arguments
cout << p1->str();
}else
{
cout << "Unknown account type: " << s << endl;
}
return 0;
}
|