+ 1

Static object importance in c++

I am aware about practical usecase of static variable like int , double etc.. Never thought of the static objects of a class.. can anyone give me practical usecase of static objects?

14th Sep 2018, 6:03 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 Answers
+ 2
One of the most important examples is Meyer's singleton. It uses static local variable which is an instance of class.
15th Sep 2018, 5:06 AM
Viacheslav
+ 1
You implement virtual function like value& get_curent_value(); But your implementation stores values at vector and you have to cover the case if the vector is empty.
15th Sep 2018, 4:46 AM
Sergey Ushakov
Sergey Ushakov - avatar
0
some default value for case when your interface function have to return reference, but there is no real value.
14th Sep 2018, 7:14 PM
Sergey Ushakov
Sergey Ushakov - avatar
0
not able to think of scenario when this situation arises
15th Sep 2018, 12:55 AM
Ketan Lalcheta
Ketan Lalcheta - avatar