Declaring Arrays of Objects - C++ Class

C++ examples for Class:object

Description

Declaring Arrays of Objects

Demo Code

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

class Employee//from   w w  w .  ja v  a  2s.  c  o  m
{
  public:
    int  workHour;
    double salary;
    double addWork(int hours, double grade){
        return 0.0;
    }
};

void myFunction()
{
    Employee s[10];

    s[4].salary = 4.0;
    s[4].workHour = 32;

    s[4].addWork(3, 0.0);
}

int main(int nNumberofArgs, char* pszArgs[])
{
    myFunction();
    cout<< "done.";
    return 0;
}

Result


Related Tutorials