Count Class Objects

How to count objects of a class ?

Questions by ajkush   answers by ajkush

Showing Answers 1 - 1 of 1 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.

Answer Question

Click here to Login / Register your free account


 
Send   Reset

 

Related Answered Questions

 

Related Open Questions