what is the error in this c++ code?

#include<iostream>
#include<string>
using namespace std;
class personType{
public:
void print() const;
void setName(string first, string last);
string getFirstName() const;
string getLastName() const;
personType(string first = "" , string last = "");
private:
string firstName;
string lastName;
};
void personType::print() const{
cout<<firstName<<" "<<lastName;
}
void personType::setName(string first,string last)
{
firstName=first;
lastName=last;
}
string personType::getLastName() const
{
return lastName;
}
personType::personType(string first, string last)
{
firstName=first;
lastName=last;
}
class partTimeEmployee: public personType
{
public:
void print() const;
double calculatePay()const;
void setNameRateHours(string first = "" , string last = "" , double rate = 0 , double hours = 0);
private:
double payRate;
double hoursWorked;
};
void partTimeEmployee::print() const
{
personType::print(); //print te name of the employee
cout<<"'s wages are: $"<<calculatePay()<<endl;
}
double partTimeEmployee::calculatePay() const
{
return (payRate*hoursWorked);
}
void partTimeEmployee::setNameRateHours(string first,string last,double rate, double hours)
{
personType::setName(first,last);
payRate=rate;
hoursWorked=hours;
}

partTimeEmployee::partTimeEmployee(string first, string last, double rate, double hours)

:personType(first, last);

{
if (rate>=0)
payRate=rate;
else
payRate=0;
if (hours>=0)
hoursWorked=hours;
else
hoursWorked=0;
}
int main()
{
partTimeEmployee newEmp ("john", "smith", 15.34, 67);
newEmp.print();
return 0;
}
Please use code tags: [code]Your code[/code]
Read this: http://www.cplusplus.com/articles/z13hAqkS/

And please describe the error as precise as possible.

At a glance: :personType(first, last) //; Note: No ; in a initalizer list
Last edited on
Topic archived. No new replies allowed.