Can i explicitly call a destructor if i''ve allocated my , C/C++ Programming

Assignment Help:

Can I explicitly call a destructor if I've allocated my object with new?


Related Discussions:- Can i explicitly call a destructor if i''ve allocated my

Implement mini version of linux ''tar'', I need to implement a mini version...

I need to implement a mini version of linux''s ''tar'' function in C.

I want auto-rank script, Project Description: I play this game called mo...

Project Description: I play this game called mobstar (mobstar) and I would like the program to grade my account for me. It would require doing a crime, GTA, jail busting, lead a

What are virtual functions in c++, A virtual function permits derived class...

A virtual function permits derived classes to replace the implementation given by the base class. The compiler makes sure the replacement is always known as whenever the object in

Fibonacci series, draw the flow chart to print the fibonacci series upto n ...

draw the flow chart to print the fibonacci series upto n th terms

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Displays the lower case and upper case alphabetical letters, Write a progra...

Write a program that displays both the lower case and upper case alphabetical letters using the following Format Lowercase        Uppercase a                        A

Data Handling in computers, though the ascii is called 7-bit code. why do w...

though the ascii is called 7-bit code. why do we use 8-bits to represent a character?

Coding, dispaly the last ant on rod

dispaly the last ant on rod

3/15/2013 5:36:19 AM

A: perhaps not.        

 Unless you utilized placement new, you must simply delete the object instead of explicitly calling the destructor. For instance, suppose you allocated the object through a typical new expression:

Fred* p = new Fred();

Then the destructor Fred::~Fred() will auto magically get called while you delete it via:

delete p; // Automagically calls p->~Fred()

You must not explicitly call the destructor, as doing so won''t release the memory which was allocated for the Fred object itself. Remember: delete p does two things: first it calls the destructor and second it deallocates the memory.

 

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd