why constructor can 27t be static in c 2b 2b

Solutions on MaxInterview for why constructor can 27t be static in c 2b 2b by the best coders in the world

showing results for - "why constructor can 27t be static in c 2b 2b"
Jana
05 Aug 2018
1static variable are those variable declared with static and i will be refer to the common property of all the objects in a java and it is mainly used for memory managment in java. constructor is used to inilialize the objects and it is automatically called at time of object creation.
2
3It is not possible in the constructor because static member variables are not associated with each object of the class. It is shared by all objects. If you initialize the static variable into the constructor then it means that you are trying to associate with a particular instance of class. Since this is not possible, it is not allowed.