I am trying to put together a program and would love someone to tell me why it is saying that my variables in my methods are undefined when they are defined in the class. The ones that are giving me errors are the one in my Administrator class that are "Set" methods.
Nevermind I figured it out.
I had to actually chang it to
//Lynette Wilkins //Week 12 #include <iostream> #include <cstdlib> #include <string> #include <iomanip> #include <cmath> using namespace std; class SalariedEmployee { private: double wageRate; int hours; protected: string name; string ssn; double netPay; string department; public: SalariedEmployee(string n, string s, double np, double w, int h, string d); ~SalariedEmployee() {cout<<endl;} string Getname(); //returns name string Getssn(); // returns social security number double GetnetPay(); //returns netPay string Getdepartment(); // returns department double GetwageRate(); //returns wage rate int Gethours(); //returns hours string Setname(string); //sets name string Setssn(string); //sets ssn double SetnetPay(double); //sets net pay string Setdepartment(string); //sets department double SetwageRate(double); //sets wage rate int Sethours(int); //sets hours }; string SalariedEmployee::Getname() { return name; } string SalariedEmployee::Getssn() { return ssn; } double SalariedEmployee::GetnetPay() { return netPay; } double SalariedEmployee::GetwageRate() { return wageRate; } int SalariedEmployee::Gethours() { return hours; } string SalariedEmployee::Setname(string n) { name = n; } string SalariedEmployee::Setssn(string s) { ssn = s; } double SalariedEmployee::SetnetPay(double np) { netPay = np; } string SalariedEmployee::Setdepartment(string d) { department = d; } double SalariedEmployee::SetwageRate(double w) { wageRate = w; } int SalariedEmployee::Sethours(int h) { hours = h; } class Administrator : public SalariedEmployee { protected: string title; string responsi; string super; double salary; public: Administrator(string t, string r, string s, double sa); ~Administrator(); string Gettitle(); string Getresponsi(); string Getsuper(); double Getsalary(); string Settitle(string); string Setresponsi(string); string Setsuper(string); double Setsalary(double); void print(); }; Administrator::~Administrator() { cout<<endl; } string Administrator::Gettitle() { return title; } string Administrator::Getresponsi() { return responsi; } string Administrator::Getsuper() { return super; } double Administrator::Getsalary() { return salary; } string Settitle(string ti) { title = ti; } string Setresponsi(string re) { responsi = re; } string Setsuper(string su) { super=su; } double Setsalary(double sa) { salary= sa; } void print( ) { cout<<"print"<<endl; } int main() { string name; string soc; double net; double wage; int hrs; string dept; string admtitle; string resp; string sup; double sal; int response; string date = "January 12, 2013"; cout<<setprecision(2) <<setiosflags(ios::fixed) <<setiosflags(ios::showpoint); SalariedEmployee emp1(name, soc, net, wage, hrs, dept); Administrator adm1(admtitle, resp, sup, sal); cout<<"Employee and Administrator Salary Program "<<endl; cout<<"(You will have to enter data first before you do anything else)"<<endl<<endl; cout<<"Enter Employee Data, Enter 1"<<endl; cout<<"Change data, Enter 2"<<endl; cout<<"Print Check, Enter 3"<<endl<<endl; cout<<"Please make your selection"<<endl; int response; cin>> response; cin.getline; switch (response) { case 1: cout <<"The employee's data will be entered here: "<<endl<<endl; cout<<"Enter the employees name: "<<endl; getline(cin, name); cout<<"Enter the employees social security number: "<<endl; getline(cin, soc); cout<<"Enter the employees net pay: "<<endl; cin>>net; cout<<"Enter the employees wage rate: "<<endl; cin>>wage; cout<<"Enter the number of hours the employer worked: "<<endl; cin>>hrs; cout<<"Enter the employees title: "<<endl; getline(cin, admtitle); cout<<"Enter the employees area responsibility: "<<endl; getline(cin, resp); cout<<"Enter the employees salary: "<<endl; cin>>sal<<endl<<endl<<endl; cout<<"Change data, Enter 2"<<endl; cout<<"Print Check, Enter 3"<<endl<<endl; cout<<"Please make your selection"<<endl; int response; cin>> response; cin.getline; break; case 2: cout<<"Please change the data you entered previously here. " <<endl<<endl; cout<<"Enter the employees name: "<<endl; getline(cin, name); cout<<"Enter the employees social security number: "<<endl; getline(cin, soc); cout<<"Enter the employees net pay: "<<endl; cin>>net; cout<<"Enter the employees wage rate: "<<endl; cin>>wage; cout<<"Enter the number of hours the employer worked: "<<endl; cin>>hrs; cout<<"Enter the employees title: "<<endl; getline(cin, admtitle); cout<<"Enter the employees area responsibility: "<<endl; getline(cin, resp); cout<<"Enter the employees salary: "<<endl; cin>>sal<<endl<<endl<<endl; cout<<"Print Check, Enter 3"<<endl<<endl; cout<<"Please make your selection"<<endl; int response; cin>> response; cin.getline; break; case 3: cout <<"Informatin Printed"<<endl<<endl; adm1.print; break; default: cout<<endl<<endl <<"Invalid Selection! Try Again"<<endl; exit(1); } system("PAUSE"); return 0; }
Nevermind I figured it out.
I had to actually chang it to
string Administrator::Settitle(string ti) { title = ti; }