Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

hr interview how many minutes asking question

2000


What is independent and dependent variables in research?

817


Which types of exceptions are caught at compile time?

986


What is the difference between equals() and == in java?

925


What is the old name of java?

929


How do you use substring in java?

1069


What are the methods of object class ?

1007


Can array grow dynamically in java?

922


What is an object in java and how is it created?

1009


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

1152


Does java support multiple inheritances?

980


What are exceptions

1042


Java Compiler is stored in JDK, JRE or JVM?

1476


What is a treeset class?

958


What happens if a constructor is declared private?

980