a problem with OOP

now that this program is based on employee entity & we are calculating employee details but it gives a hell of errors plase correct this code i cant understand any of thse errors

the coding is given below

#include<iostream>
#include<cstring>
using namespace std;

class employee {
private:
int empno;
char name[20];
double basicsal;
double othrs;
double otrate;
double allowace;
public:
employee(int pempno,char pname[],double,pbasicsal);
void setotdetails(int pothrs,int potrate);
void setallowance(int pallowance);
void calcsal();
void printpayslip();
};

employee::employee(int pempno,char pname[],double pbasicSal)
{
empno=pempno;
strcpy(name,pname)
}
void employee::setOtDetails(int potHrs,int potRate)
{
otHrs=potHrs;
otRate= potRate;
}
void employee::setAllowance(int pallowance);
{
allowance=pallowance;
}
void employee::calcSal(double basicSal);
{
sal=basicSal+allowance+otHrs*otRate;
}
void employee::printPaySlip();
{
cout<<"empno"<<empno<<endl;
cout<<"salary"<<sal<<endl;
"employee.cpp" [readonly] 24L, 450C 23,1 Top
}
int main()
{
employee emp1(10,"wimal",5000);
emp1.setotdetails(20,100);
emp1.setallowance(1500);
emp1.calcsal();
emp1.printpayslip();

return 0;
}
~


PS originally this program was modularized to 3 parts like class to a header file & the main as a seperate program & the functions or methods as a seperate program

Last edited on
I just skimmed through the code.
What I think that is generally wrong:

In the declaration of the functions you use variables with a p in the beginning. I guess you are using pointers,. So I think it must state

 
void employee::setOtDetails(int *potHrs,int *potRate)


in main

Last edited on
I've reproduced your code with the tags to use the line numbers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<iostream>
#include<cstring>
using namespace std;

class employee {
private:
int empno;
char name[20];
double basicsal;
double othrs;
double otrate;
double allowace;
public:
employee(int pempno,char pname[],double,pbasicsal);
void setotdetails(int pothrs,int potrate);
void setallowance(int pallowance);
void calcsal();
void printpayslip();
};

employee::employee(int pempno,char pname[],double pbasicSal)
{
empno=pempno;
strcpy(name,pname)
}
void employee::setOtDetails(int potHrs,int potRate)
{
otHrs=potHrs;
otRate= potRate;
}
void employee::setAllowance(int pallowance);
{
allowance=pallowance;
}
void employee::calcSal(double basicSal);
{
sal=basicSal+allowance+otHrs*otRate;
}
void employee::printPaySlip();
{
cout<<"empno"<<empno<<endl;
cout<<"salary"<<sal<<endl;
"employee.cpp" [readonly] 24L, 450C 23,1 Top
}
int main()
{
employee emp1(10,"wimal",5000);
emp1.setotdetails(20,100);
emp1.setallowance(1500);
emp1.calcsal();
emp1.printpayslip();

return 0;
}

Line 14, you have a comma between double and pbasicsal.
Line 24, needs semi-colon on the end.
Lines 15/26 etc. You have mixed upper and lower case for all you method names and their prototypes. C++ is case sensitive. You have also put semi-colons at the end of lines 31, 35, and 39 which shouldn't be there.
Lines 17/35/50: The parameters need to be the same.
Lines 28/29/37, again upper/lower case mismatch with member definitions on lines 10 and 11.
Line 12 typo allowance needs an 'n'
Line 37/42 you need to define variable sal.


I think that's all of them
Topic archived. No new replies allowed.