How many objects are created for a singleton class
Answer Posted / utkarsh verma
c++ program to explain Singleton
class Single {
private:
Single(){} //Can't instantiate
public:
Static Single* Obj;
Static *Single Instance ()
{
if(Obj == NULL)
Obj = new Single();
return Obj;
}
}//End of class
Single * Single ::Obj = NULL;
void main(){
Single *ptr = Obj->Instance(); //The only way to instantiate
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What are the common uses of "this" keyword in java ?
Can you instantiate the math class in Java?
How many bits is a string?
What methodology can be utilized to link to a database?
What is lambda expression in java?
What do you mean Abstraction in java?
What is the benefit of inner / nested classes ?
Differentiate between stringbuffer and string?
What is your platform’s default character encoding?
Why can't we use static class instead of singleton?
What is a map in java?
What is an abstract class and what is it’s purpose?
What is boolean used for?
What is difference between array and arraylist in java?
Give an example of use of pointers in java class.