I need help with this C++ program. Please help?

• name. A string that holds the employee’s name.

• idNumber. An int variable that holds the employee’s ID number.

• department. A string that holds the name of the department where the employee works.

• position. A string that holds the employee’s job title.

The class should have the following constructors:

• A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee’s name, employee’s ID number, department, and position.

• 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 (“ “);

• A default constructor that assigns empty strings (“ “) to the name, department, and position member variables, and 0 to the idNumber member variable.

Write appropriate mutator functions that store values in these member variables and accessor functions that return the values in these member variables. Once you have written the class, create a three Employee objects (3 separate instances), in your main function, to hold the following data.

Name ID Number Department Position

Susan Meyers 47899 Accounting Vice President

Mark Jones 39119 IT Programmer

Joy Rogers 81774 Manufacturing Engineer

1 Answer

Relevance
  • 8 years ago
    Favorite Answer

    the main problem when solving a problem is how to create a class. Ok i create the class for u and the rest u do urself. you are lazy lazy lazyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy............

    #include <iostream.h>

    #include <conio.h>

    #include <string.h>

    class Employee

    {

    private:

    char name[25];

    int idNumber;

    char department[20];

    char position[20];

    public:

    Employee( char *n, int id, char *dep, char *pos )

    {

    strcpy( name, n );

    idNumber = id;

    strcpy( department, dep );

    strcpy( position, pos );

    }

    Employee( char *n, int id )

    {

    strcpy( name, n );

    idNumber = id;

    strcpy( department, "" );

    strcpy( position, "" );

    }

    void setName( char *n )

    {

    strcpy( name, n );

    }

    void setIdNumber( int i )

    {

    idNumber = i;

    }

    void setDepartment( char *dep )

    {

    strcpy( department, dep );

    }

    void setPosition( char *pos )

    {

    strcpy( position, pos );

    }

    char* getName( void )

    {

    return name;

    }

    int getIdNumber( void )

    {

    return idNumber;

    }

    char* getDepartment( void )

    {

    return department;

    }

    char* getPosition( void )

    {

    return position;

    }

    };

    int main()

    {

    Employee e1( "d" , 2 );

    e1.setName( "abc" );

    e1.setIdNumber( 100 );

    e1.setDepartment( "Cilinic" );

    e1.setPosition( "Sen" );

    cout << endl << e1.getName()

    << endl << e1.getIdNumber()

    << endl << e1.getDepartment()

    << endl << e1.getPosition() << endl;

    system( "pause" );

    getch();

    return 0;

    }

    we could make better program than this using the concept of "Dynamic Memory Allocation" but i have given you the Solution...

    i want to become the most famous PROGRAMMERrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.........................

    Source(s): I myself am Source i don't like Copy . i hate Copyyyyyyyyyyyyyyyyyy......
Still have questions? Get your answers by asking now.