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 do you understand by classes in java?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?
How can you set an applet’s height and width as a percentage?
What does void * mean?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
What is a class variable?
Can an interface have a class?
What are the advantages of arraylist over arrays?
Name some classes present in java.util.regex package.
What are the different ways to handle exceptions?
What is instance means in java?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What is Major and importance difference between for and foreach loop ?
What is the purpose of void?
What is tree node in java?