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

Board colouring, in this problem you are given a board in which some of the...

in this problem you are given a board in which some of the elements are placed..each element represent ancolor.fill the other elements in the board such that none of the adjacent e

What is scope resolution operator, Scope Resolution operator: The scope...

Scope Resolution operator: The scope resolution operator: : is used to access global variable in the inner block. When global and local variable are identical name the scope re

Microprocessor programming, I need to program a microprocessor that would h...

I need to program a microprocessor that would have a temperature, gas, humidity and PIR sensor connected to it. It would send the data to a PC via a Zigbee and receive commands fro

File, how i can open a file

how i can open a file

Input, I want to take 1.1 as input but when I am declaring it as float the ...

I want to take 1.1 as input but when I am declaring it as float the output is given as 1.1000000

Loop statement, write a c++ program to accept 3 numbers and find the larges...

write a c++ program to accept 3 numbers and find the largest of 3 numbers

Is always the default constructor for fred fred::fred()?, Is always the def...

Is always the default constructor for Fred Fred::Fred()?

C program to create, Aim: To implement a program to create, update & displ...

Aim: To implement a program to create, update & display account & admin record of person using display account & admin records of person using virtual base class.. Code:

Tells the operators one can override; which operators , Q:  Tells the opera...

Q:  Tells the operators one can override; which operators should he override? A: Bottom line: don't puzzle your users. Remember the reason of operator overloading: to decreas

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