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 meant by bytecode?
What are the two categories of data types in the java programming language?
How do I get a substring?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
What is split return?
How will you call an Applet using Java Script Function?
Does treeset use compareto?
How the metacharacters are different from the ordinary characters?
Why we use set in java?
java program with complete 4 oops concepts implemented example
Explain 5 io best practices?
Can an interface be defined inside a class?
Explain thread in java?
What is a line break?
What is a constructor overloading in java?