class cSimple { private: int icount; int iLoopValue; public: //always constructure must be in public cSimple() { icount=0; } cSimple(int iTemp) { iLoopValue=iTemp; } void MyFunction() { for(;icount<iLoopValue;icount++) cout<<"The count value is :"<<icount<<endl; } };
cSimple() { if(CommonInit() != 0){error handling} } cSimple(int iTemp) { if(CommonInit() != 0){error handling} iLoopValue=iTemp; } int CSimple::CommonInit() { icount = 0; iLoopValue = 0; //Don't leave any members uninitialized return 0; }
cSimple myS; // Normal constructor call, creates the object myS.cSimple::cSimple(134); // Explicit constuctor call on an existing object
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)