How can i design, To calculate's the objects in a class
-
Hai, plz help me , 1) i want to design a program that should calculate's the objects in a class. in which way i design that problem . plz help -- modified at 5:21 Monday 14th August, 2006
Hi, Thanks, if u think it's good. otherwise sorry.
-
Hai, plz help me , 1) i want to design a program that should calculate's the objects in a class. in which way i design that problem . plz help -- modified at 5:21 Monday 14th August, 2006
Hi, Thanks, if u think it's good. otherwise sorry.
U r looking for objects in a class or objects of a class? If it is the later, ie how to track the the number of objects created for a class, u can use below demo.
class InstanceCntDemo{ private : static int nCnt; public: InstanceCntDemo(){ nCnt++; } static int GetCnt() { return nCnt; } }; int InstanceCntDemo::nCnt =0; int main(){ InstanceCntDemo ic; InstanceCntDemo ic1; InstanceCntDemo ic2; InstanceCntDemo ic3; int nCnt = InstanceCntDemo::GetCnt(); };
Does this make sense? Cheers MiltonKB. -
U r looking for objects in a class or objects of a class? If it is the later, ie how to track the the number of objects created for a class, u can use below demo.
class InstanceCntDemo{ private : static int nCnt; public: InstanceCntDemo(){ nCnt++; } static int GetCnt() { return nCnt; } }; int InstanceCntDemo::nCnt =0; int main(){ InstanceCntDemo ic; InstanceCntDemo ic1; InstanceCntDemo ic2; InstanceCntDemo ic3; int nCnt = InstanceCntDemo::GetCnt(); };
Does this make sense? Cheers MiltonKB.Thanks Mr.MiltonKB.
Hi, Thanks, if u think it's good. otherwise sorry.