I'm getting an error in main() saying TitledEmployee is an undeclared identifier?
#include <iostream>
#include <string>
using namespace std ;
namespace Employees
{
class Employee
{
public:
Employee ( ) ;
Employee ( string theName , string theSsn ) ;
string getName ( ) const ;
string getSsn ( ) const ;
double getNetPay ( ) const ;
void setName ( string newName ) ;
void setSsn ( string newSsn ) ;
void setNetPay ( double newNetPay ) ;
void printCheck ( ) const ;
private:
string name ;
string ssn ;
double netPay ;
} ;
Employee::Employee ( ) : name ( "No name yet" ) , ssn ( "No number yet" ) , netPay ( 0 )
{ }
Employee::Employee ( string theName , string theNumber ) : name ( theName ) , ssn ( theNumber ) , netPay ( 0 )
{ }
string Employee::getName ( ) const
{
return name ;
}
string Employee::getSsn ( ) const
{
return ssn ;
}
double Employee::getNetPay ( ) const
{
return netPay ;
}
void Employee::setName ( string newName )
{
name = newName ;
}
void Employee::setSsn ( string newSsn )
{
ssn = newSsn ;
}
void Employee::setNetPay ( double newNetPay )
{
netPay = newNetPay ;
}
void Employee::printCheck ( ) const
{
cout << "\nERROR: printcheck Function Called for an unidentified employee.\nAborting the program.\n" ;
exit ( 1 ) ;
}
class SalariedEmployee : public Employee
{
public:
SalariedEmployee ( ) ;
SalariedEmployee ( string theName , string theSsn , double theWeeklySalary ) ;
double getSalary ( ) const ;
void setSalary ( double newSalary ) ;
void printCheck ( ) ;
private:
double salary;
} ;
SalariedEmployee::SalariedEmployee ( ) : Employee ( ) , salary ( 0 )
{ }
SalariedEmployee::SalariedEmployee ( string theName , string theNumber , double theWeeklyPay ) : Employee ( theName , theNumber ) , salary ( theWeeklyPay )
{ }
double SalariedEmployee::getSalary ( ) const
{
return salary ;
}
void SalariedEmployee::setSalary ( double newSalary )
{
salary = newSalary ;
}
void SalariedEmployee::printCheck ( )
{
setNetPay ( salary ) ;
cout << "\n____________________________\n" ;
cout << "Pay to the order of " << getName ( ) << endl ;
cout << "The sum of " << getNetPay ( ) << " Dollars\n" ;
cout << "______________________________\n" ;
cout << "Check Stub Non Negotiable \n" ;
cout << "Employee Number: " << getSsn ( ) << endl ;
cout << "Salaried Employee. Regular Pay: " << salary << endl ;
cout << "______________________________\n" ;
}
class TitledEmployee : public SalariedEmployee
{
public:
TitledEmployee ( ) ;
TitledEmployee ( string theName , string theTitle , string theSsn , double theSalary ) ;
string getTitle ( ) const ;
void setTitle ( string theTitle ) ;
void setName ( string theName ) ;
private:
string title ;
} ;
TitledEmployee::TitledEmployee ( ) : SalariedEmployee ( ) , title ( "No title yet" )
{ }
TitledEmployee::TitledEmployee ( string theName , string theTitle , string theSsn , double theSalary ) : SalariedEmployee ( theName , theSsn , theSalary ) , title ( theTitle )
{ }
void TitledEmployee::setName ( string theName )
{
Employee::setName ( title + theName ) ;
}
}//end Employees namespace
int main ( )
{
TitledEmployee frank ;
TitledEmployee bob ( "Bobby Goodsworth" , "Sir" , "123-45-6789" , 2500.00 ) ;
frank.setTitle ( "Mr." ) ;
return 0 ;
}