-
WHO can solve this???
Create a class called Company which contains a pointer called PtrArr which is used to point an array of employee objects and 1 integer data member. The integer data member will be used to store the number of existing employee currently. [make sure you have a proper constructors to create the array for the pointer] Include the following member functions:-
I. Insert new Employee (to insert new employee object into the array. Make proper validations on appropriate fields. The employee_no is auto generated based on the number of objects created)
II. Update (to search a employee base on the employee_no and allow the user to modify all data except employee_no)]
III. Report based on employee_type and then based on gender. The employee records must be sorted based on employee_name.
IV. Report based on employee age (display employee records between age ranges). To find the age, calculate the employee year from today’s year.
-
You?
What exactly are you struggling with? Or do you just expect someone to write the codez for you?
--
Mats
-
is it the question a) correct ?
answer>
Code:
class Employee{
int emp.no;
char emp_name[20];
char gender;
string DOB;
char type[3];
public:
employee9int emp.no, char emp_name,
char gender, string DOB,
char type){
emp_no=emp_no;
emp_name=emp_name;
gender = gender;
DOB = DOB;
type = type;
}
employee(int no, char name, char, char gen,
stirng birth,char type){
emp.no=no;
emp_name=name;
gender=gen;
DOB=birth;
type=type;
}
1)void setNo(int no){
emp_no=no;
}
2)void setName(char name){
emp_name = name;
}
1)int getNo(void){
return emp_no;
}
int row,col;
for(row=0; row<4; row++){
for(col=0;col<=row;col++){
cout<<"*";
}
cout<<"\n";
}
int dimension[5][6];
char
and the b) is it same with the a) ??
wht is that PtrArr ??
-
It would help if you use code-tags and indent the text
Code:
employee(int emp.no, char emp_name, char gender, string DOB, char type)
{
emp_no=emp_no;
emp_name=emp_name;
gender = gender;
DOB = DOB;
type = type;
}
The above code does "nothing", since both sides of the assignment is the same variable - assigning "x = x" will do "nothihng", since x on the left-hand side already has the value of x on the right-hand side. It is common to name inputs to a constructor differently than the member variables (either changing the member variables or the constructor parameters - or both if you were to follow the coding standard where I work), but if you insist on hiding the members with the parameter names, you can do "this->x = x";
You have two implementations of the constructor. Your getters and setters are not declared in the class declaration, nor are they prefixed with the class name.
I'm not sure what your row/col loops are for at the end of your post...
--
Mats
-
thank you very much matsp i got it already for the question a)
-
Also, check your textbook again for valid variable names.
emp.no is not a valid variable name. If emp was the name of some struct which had a member called no, then it would be valid, but it's definitely not valid for an int.
emp_no is valid, as is empNo...
Only numbers, letters and underscores are allowed in names, and it cannot begin with a number.
-
ohhhh.....
thanks for ur help cpjust