about constructors

Can you tell me how to write the constructor for this?

A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name and ID number. The department and position fields should be assigned an empty string (” ”).

This is what I get:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  Employee(string n,int i,string d ,string p) // n,i,d,p is the first letter of the variables
	{
		n = "Sam";
		i = 123;
		d = " ";
		p = " ";
		name(n);
		idNumber(i);
		department(d);
		position(p);
	}
// another version:
Employee(string n,int i,string d ,string p)
	{
		n = "Sam";
		i = 123;
		d = " ";
		p = " ";
		name = n;
		idNumber = i;
		department = d;
		position = p;
        }

Is there any advice for these constructors?
Last edited on
Topic archived. No new replies allowed.