second attempt at class problem

ok here is the code and then the errors.....just dont see how to fix these errors

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

/* christopher bruce

payroll class header file
*/

#include <string>
using namespace std;


class payroll
{
	int hours;
	double hourlyrate;
	double grosspay;
	int maxhours;

}

/*
	christopher bruce
	employee class header file
*/
#include <string>
using namespace std;

	class employee
{
	string firstname;
	string lastname;
	const char* idnum;
	string dept;
	string position;

};

#include <iostream>
#include <cmath>
#include <string>
#include <fstream>
#include "employee.h";
#include "payroll.h";

using namespace std;

int hours;
double hourlyrate;
double grosspay;
int maxhours;


employee::employee ()
{
	employee employee1;
	employee employee2;
	employee employee3;
	
	employee1.firstname = "susan";
	employee1.lastname = "meyers";
	employee1.idnum = "47899";
	employee1.dept = "accounting";
	employee1.position = "vice president";

	employee2.firstname = "mark";
	employee2.lastname = "jones";
	employee2.idnum = "39119";
	employee2.dept = "it";
	employee2.position = "programer";
	
	employee3.firstname = "joy";
	employee3.lastname = "rogers";
	employee3.idnum = "81774";
	employee3.dept = "manufacturing";
	employee3.position = "engineer";
	cout << employee1.firstname << " " << employee1.lastname << " id number: " << employee1.idnum << " " << employee1.dept << " " << employee1.position << endl;
	cout << employee2.firstname << " " << employee2.lastname << " id number: " << employee2.idnum << " " << employee2.dept << " " << employee2.position << endl;
	cout << employee3.firstname << " " << employee3.lastname << " id number: " << employee3.idnum << " " << employee3.dept << " " << employee3.position << endl;
}


void payroll ()
{
	cout << "please enter the payrate:";
	cin >> hourlyrate;
	cout << "please enter the hours:";
	cin >> hours;
	if (hours > 60)
	{
		hours = 0;
		cout << "hours must be less then 60. ";
		cout << "please reenter hours:"; 
		cin >> hours;
	}
	else 
	{
		grosspay = hourlyrate * hours;
	}
}

void main ()
{
	
	cout << "here are three random employees from a random compony" << endl;

		
};


Error 1 error C2143: syntax error : missing ';' before 'using' c:\documents and settings\allisa\my documents\visual studio 2010\projects\classes\classes\class.cpp 7 1 classes

Error 3 error C2264: 'employee::employee' : error in function definition or declaration; function not called c:\documents and settings\allisa\my documents\visual studio 2010\projects\classes\classes\class.cpp 17 1 classes

this error times 3

Error 2 error C2600: 'employee::employee' : cannot define a compiler-generated special member function (must be declared in the class first) c:\documents and settings\allisa\my documents\visual studio 2010\projects\classes\classes\class.cpp 16 1 classes
You forgot to tell the compiler that you are not using the default constructor in the employee class declaration create a constructor.
http://www.cplusplus.com/doc/tutorial/classes/

By the way it is int main () not void main () and main does not need a semicolon after the brackets.

Hope this helps :)
ok i get the point, but am unsure of the correct syntax, because i thought that that is what i was doing in the main cpp file when i put in employee:employee () (line 52)
ok figured it out/....thanks
Topic archived. No new replies allowed.