C++ Constructor called within an array of objects

Description

C++ Constructor called within an array of objects

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

class Employee{//from   ww w  .ja v a  2  s .c om
  public:
    Employee(){
        cout << "constructing employee" << endl;
        workHour = 0;
        salary = 0.0;
    }
  protected:
    int  workHour;
    double salary;
};

int main(int nNumberofArgs, char* pszArgs[])
{
    cout << "Creating an array of 5 Employee objects" << endl;
    Employee s[5];

    return 0;
}



PreviousNext

Related