C++ | Static Keyword | Question 2
(A) Compiler Error
(B) 1 2 3
(C) 1 1 1
(D) 3 3 3
(E) 0 0 0
Explanation: If a member variable is declared static, all objects of that class have access to a single instance of that variable. Static variables are sometimes called class variables, class fields, or class-wide fields because they don’t belong to a specific object; they belong to the class.
In the above code, static variable next_id is used to assign a unique id to all objects.
My Personal Notes arrow_drop_up
Please Login to comment...