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 is ternary operator?
How is abstraction implemented in java ?
What is the common usage of serialization? What exceptions occur during serialization?
What is meant by memory leak?
What is parsing a string?
Which keyword specify that a variable is effectively final ?
What is java autoboxing?
What is identifier give example?
What is the final class modifier?
What is the difference between assignment and initialization?
How do you start a new line in java?
How many bits is a double?
Can we have any code between try and catch blocks?
Why declare Main() inside the class in java ?
What happens if an exception is throws from an object's constructor?