Update but still not working
ok, here is how i updated the code, but i am still having the same problem. did i miss something you were saying?
Code:
// paycenter.cpp
// Program to calculate overtime pay for employees
#include <iostream> //for stream I/O
#include <cstring> //for strlen() and strcpy()
using std::cout;
using std::cin;
using std::endl;
class Cemployee
{
public:
char* m_name;
double m_hours;
float m_wage;
Cemployee(const char* str = "employee name", double hv = 1, float wv = 1): m_hours(hv),m_wage(wv)
{
m_name = new char[ strlen(str) + 1];
strcpy_s(m_name, strlen(str) + 1, str);
}
~Cemployee(void)
{ delete[] m_name; }
const double gethours(void) const
{
return m_hours;
}
const float getwage(void) const
{
return m_wage;
}
const char* getname(void) const
{
return m_name;
}
};
int main()
{
char* name;
double hours;
float wage;
cout << "Welcome to the Employee Pay Center" << endl << endl;
cout << "Enter the employee name = ";
cin >> name;
cout << endl << "Enter the hours worked = ";
cin >> hours;
cout << endl << "Enter his or her hourly wage = ";
cin >> wage;
Cemployee emp1;
emp1.m_wage = wage;
emp1.m_hours = hours;
emp1.m_name = name;
cout << endl << endl << endl;
cout << "name " << emp1.getname();
cout << endl << "wage " << emp1.getwage();
cout << endl << "hours " << emp1.gethours() << endl;
system("pause");
return 0;
}