Count Class Objects

How to count objects of a class ?

Questions by ajkush   answers by ajkush

Showing Answers 1 - 3 of 3 Answers

Jayesh v Bhatu

  • Jul 31st, 2016
 

Declare a static count variable in and increment in constructor.

For ex:
class A{
static int count=0;
A(){
count++;
}
}

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions