What is the difference between private static variable and private instance variable in a singleton class?
I see no semantic difference.
EDIT: Not asking if the variable holding the instance of itself should be static, but other data members.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The way I see it, there is only “no semantic difference” if you assume that the singleton is implemented using a
staticreference to the single instance. The thing is,staticis just one way to implement a singleton — it’s an implementation detail. You can implement singletons other ways, too.