WHO can solve this???

This is a discussion on WHO can solve this??? within the C++ Programming forums, part of the General Programming Boards category; Create a class called Company which contains a pointer called PtrArr which is used to point an array of employee ...

  1. #1
    Registered User
    Join Date
    Aug 2008
    Posts
    8

    Wink 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.
    Last edited by scjohnny; 08-11-2008 at 05:41 AM.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You?

    What exactly are you struggling with? Or do you just expect someone to write the codez for you?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Posts
    8
    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 ??
    Last edited by Salem; 08-11-2008 at 09:54 AM. Reason: Fixed code tags, but it's no use as there's no indentation either :(

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    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
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Aug 2008
    Posts
    8
    thank you very much matsp i got it already for the question a)
    Last edited by scjohnny; 08-11-2008 at 05:42 AM.

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    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.

  7. #7
    Registered User
    Join Date
    Aug 2008
    Posts
    8
    ohhhh.....
    thanks for ur help cpjust

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can anyone solve this for me? (look inside)
    By johnsonswww in forum C Programming
    Replies: 10
    Last Post: 03-02-2009, 10:24 AM
  2. Replies: 2
    Last Post: 04-25-2005, 11:59 AM
  3. How to handle in software to solve this block diagram?
    By vnrabbit in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 01:45 PM
  4. Help to solve this problem
    By Romashka in forum C++ Programming
    Replies: 3
    Last Post: 04-16-2002, 09:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21