Horje
why constructor can't be static in c++ Code Example
why constructor can't be static in c++
static 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.

It 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.




Cpp

Related
c++ vector declaration Code Example c++ vector declaration Code Example
c++ rand Code Example c++ rand Code Example
c++ switch integer Code Example c++ switch integer Code Example
1822. Sign of the Product of an Array leetcode Code Example 1822. Sign of the Product of an Array leetcode Code Example
find maximum contiguous Sub arrays Code Example find maximum contiguous Sub arrays Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7