C++ Array of objects create

Description

C++ Array of objects create

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string.h>

using namespace std;
class Employee//from  w w  w . ja  v  a2s.c om
{
  public:
    Employee(const char *pName)
    {
        cout << "constructing freshman " << pName << endl;
        name = pName;
        workHour = 0;
        salary = 0;
    }
    Employee(const char *pName, int xfrHours,double xSalary)
    {
        cout << "constructing transfer " << pName << endl;
        name = pName;
        workHour = xfrHours;
        salary = xSalary;
    }

  protected:
    string  name;
    int     workHour;
    double  salary;
};

int main(int argcs, char* pArgs[])
{
    Employee s[]{"H", "P"};
    Employee t[]{{"J", 0, 0.0}, 
                {"S", 12, 2.5}};

    return 0;
}



PreviousNext

Related