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 int argc char * argv?
What is instance example?
How do you reverse a list?
Can you start a thread twice in Java?
What is the point of polymorphism java?
Can java arraylist hold different types?
What is protected access modifier?
Can we serialize static variables in java?
What is sizeof () operator?
What two classes are used to read data only?
What is the diffrence between inner class and nested class?
How does queue work in java?
whar are the draw backs of programming lang step by step in Clang and next in C++ and next and in Java nad in .Net
What are different access specifiers in java?
What is a singleton class in Java?