C++ Constructor Constructing a single object
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; class Employee/*from w w w. j a v a2 s . co m*/ { public: Employee() { cout << "constructing employee" << endl; workHour = 0; salary = 0.0; } protected: int workHour; double salary; }; int main(int nNumberofArgs, char* pszArgs[]) { cout << "Creating a new Employee object" << endl; Employee s; cout << "Creating a new object off the heap" << endl; Employee* pS = new Employee; return 0; }