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...

Do we have private destructors?

Answer Posted / sampurna pandey

yes, we can have both private constructor and destructor
and can use them with help of static function for example

class Base
{
static int i;
Base(){}
~Base(){}
public:
static Base *Creat_Object();
static void Destroy_Object(Base *p);
void Add()
{
cout<<i<<" Add function"<<endl;
}
};

int Base::i=0;
Base* Base::Creat_Object()
{
Base * ptr = new Base();
i=5;
return ptr;
}

void Base::Destroy_Object(Base *p)
{
delete p;
}

void main()
{
Base *temp = Base::Creat_Object();
temp->Add();
Base::Destroy_Object(temp);
}

correct me if i am wrong.

Is This Answer Correct ?    21 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of ::(scope resolution operator)?

1021


what is pre-processor in C++?

1092


Describe exception handling concept with an example?

988


What language does google use?

1082


What are advantages of using friend classes?

1017


What is the advantage of c++ over c?

969


What is a breakpoint?

961


Explain function overloading and operator overloading.

1022


What is a base class?

1052


What is expression parser in c++

2420


Will this c++ program execute or not?

1021


Which operator cannot be overloaded c++?

969


Explain the operation of overloading of an assignment operator.

1113


Can recursive program be written in C++?

1186


Can you please explain the difference between overloading and overriding?

1028