C++ Constructor create member objects
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; class Course/*ww w . j ava 2s . co m*/ { public: Course(){ cout << "constructing course" << endl;} }; class Employee { public: Employee() { cout << "constructing employee" << endl; workHour = 0; salary = 0.0; } protected: int workHour; double salary; }; class Manager { public: Manager(){cout << "constructing teacher" << endl;} protected: Course c; }; class JobTeam { public: JobTeam() { cout << "constructing jobTeam" << endl; noMeetings = 0; } protected: Employee employee; Manager teacher; int noMeetings; }; int main(int nNumberofArgs, char* pszArgs[]) { cout << "Creating JobTeam object" << endl; JobTeam tp; return 0; }