Submitted Questions

  • Count Class Objects

    How to count objects of a class ?

    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++;
    }
    }