Whats wrong with my calculation??

Hi last night i posted a problem, and a few of you guys kindly helped out!!

I now have got rid of all the errors and it runs!! However it will not work out the calculation it gives me a very strange no. likr 6.873546474+008 whicj is not the answer lol!

Here is all the code and i apoligise in advance if i have not laid it out correctly!!

Employee class


#pragma once
#include <iostream>


using namespace std;

class Employee
{
protected:
char* Plname;
char* Pfname;
int hours_worked;
int hourly_rate;
int final_pay;

public:
Employee()
{
Plname = NULL;
Plname = new char;
Pfname = NULL;
Pfname = new char;
hours_worked = 0;
hourly_rate = 0;
final_pay = 0;
}


void get_emp_details();
virtual double calc_pay() = 0;
void show_details();


};

inline void Employee::get_emp_details()
{
cout << " Enter Surname ";
cin.getline(Plname, 20);
cin.ignore(1, '\n');
cout << " Enter First Name ";
cin.getline(Pfname, 20);
cin.ignore(1, '\n');
do
{
cout << " Enter hours Worked ? ";
cin >>hours_worked;
}
while (hourly_rate <0 || hourly_rate >40);

cout << " Enter Hourly Rate ? ";
cin >>hourly_rate;
}


void Employee::show_details()
{
cout << " Your final Salay is " << calc_pay() << " Based on " << hours_worked << " Worked " <<endl;
}

#pragma once
#include "Employee.h"
#include <iostream>

using namespace std;

class Manager:public Employee
{
protected:
double bonus;
int final_pay;
int hours_worked;
int hourly_rate;


public:
Manager():Employee(){}
void get_bonus(Manager& m1);
virtual double calc_pay();
};

void Manager::get_bonus(Manager& m1)
{
m1.get_emp_details();
cout << " Enter Bonus ";
cin >> bonus;
}

inline double Manager::calc_pay()
{
return (hours_worked * hourly_rate) + bonus;
}

#pragma once
#include "Manager.h"
#include "Employee.h"
#include <iostream>


using namespace std;


int main()
{
Manager m1;

Employee* pEmp1 = 0;

pEmp1 = &m1;
m1.get_bonus(m1);
pEmp1 ->show_details();

}
The Manager class defines 'hours_worked' and 'hourly_rate' which are already defined in the Employee class and hence hide them. Plus the Manager class doesn't initialze its variables.
Topic archived. No new replies allowed.