![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 5
Rep Power: 0
![]() |
Employee Class/Implementation help
#include <iostream.h>
const unsigned LastNameSize = 10;
class Employee {
public:
Employee E1( long id );
Employee E2( long id, char lastName, float payRate, int hours );
long GetId();
char * GetLastName();
float GetPayRate();
int GetHours();
int CalcGrossPay();
void Display() const;
int SetHours();
int SetPayRate();
friend ostream & operator <<( ostream & os, const Employee & E);
friend istream & operator >>( istream & input, Employee & E);
~Employee()
{
cout << "Employee class destructor called.\n";
}
private:
float setpayRate;
int sethours;
};My class. ^ #include "employee.h"
Employee::SetHours( int hours )
{
sethours = hours;
}
Employee::SetPayRate( float payRate )
{
setpayrate = payRate;
}
Employee::Display() const
{
cout << "Weekly gross pay: " << CalcGrossPay();
}
Employee::GetLastName()
{
char lastName[LastNameSize];
char ch = '\0';
int i = 0;
cout << "Enter last name: ";
while(1)
{
cin.get(ch);
if( ch == '\n') break;
name[i++] = ch;
}
name[i] = '\0';
}
Employee::GetId()
{
long id;
cout << "Please enter ID number: ";
cin >> id;
}
Employee::GetHours()
{
int hours;
cout << "Please enter hour amount: ";
cin >> hours;
}
Employee::GetPayRate()
{
float payRate;
cout << "Please enter pay rate: ";
cin >> payRate;
}
Employee::CalcGrossPay()
{
return hours * payRate;
}My implementation of the class. ^ As far as the test program is concerned, I can figure that out on my own. However, the overall goals are to make ways to set and retrieve certain fields, construct and destruct an object made from Employee and to calculate the pay while having the Employee object initialize as either E1 or E2. And just for kicks, =P, the program constructs, initializes and displays the objects, and calculates/displays the gross pay for the week for one employee. Basically, I've tried my best to do this but I've run into a plethora of syntax errors due to my lack of skills with C++. With that said, here's my error log: (4): error C2511: 'int Employee::SetHours(int)' : overloaded member function not found in 'Employee'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\useoldio.h(29): warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated
c:\Documents and Settings\nerdfiles\My Documents\Projects\C++\PayrollApplication\main.cpp(5): error C2065: 'Display' : undeclared identifier
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\useoldio.h(29): warning C4995: '_OLD_IOSTREAMS_ARE_DEPRECATED': name was marked as #pragma deprecated
(9): error C2511: 'int Employee::SetPayRate(float)' : overloaded member function not found in 'Employee'
(14): error C2556: 'int Employee::Display(void) const' : overloaded function differs only by return type from 'void Employee::Display(void) const'
(14): error C2371: 'Employee::Display' : redefinition; different basic types
(15): error C2662: 'Employee::CalcGrossPay' : cannot convert 'this' pointer from 'const Employee' to 'Employee &'
(19): error C2556: 'int Employee::GetLastName(void)' : overloaded function differs only by return type from 'char *Employee::GetLastName(void)'
(19): error C2040: 'Employee::GetLastName' : 'int (void)' differs in levels of indirection from 'char *(void)'
(29): error C2065: 'name' : undeclared identifier
(29): error C2109: subscript requires array or pointer type
(31): error C2109: subscript requires array or pointer type
(35): error C2556: 'int Employee::GetId(void)' : overloaded function differs only by return type from 'long Employee::GetId(void)'
c:\Documents and Settings\nerdfiles\My Documents\Projects\C++\PayrollApplication\Employee.h(9) : see declaration of 'Employee::GetId'
(35): error C2371: 'Employee::GetId' : redefinition; different basic types
c:\Documents and Settings\nerdfiles\My Documents\Projects\C++\PayrollApplication\Employee.h(9) : see declaration of 'Employee::GetId'
(49): error C2556: 'int Employee::GetPayRate(void)' : overloaded function differs only by return type from 'float Employee::GetPayRate(void)'
(49): error C2371: 'Employee::GetPayRate' : redefinition; different basic types
(57): error C2065: 'hours' : undeclared identifier
(57): error C2065: 'payRate' : undeclared identifier
(57): error C2296: '*' : illegal, left operand has type ''unknown-type''
(57): error C2297: '*' : illegal, right operand has type ''unknown-type''Any help is greatly appreciated. (= |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|