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

Define register simply with bit fields, Define register with bit fields? ...

Define register with bit fields? We could define register simply with bit fields: struct DISK_REGISTER { unsigned ready:1; unsigned error_occured:1; unsigned disk_spinni

Assyrian keyboard for android, Project Description: I want an app that t...

Project Description: I want an app that the user can download it from the play store and use it as a keyboard for texts and writing. Just like the Samsung keyboard and the arabi

Introduction to c, All languages are divided into six sections: - variables...

All languages are divided into six sections: - variables, I/O maths, conditional expressions, arrays, functions, subroutines and file handlers. Learning a software language is simi

Explain type casting, Type Casting Implicit type conversions, as allowe...

Type Casting Implicit type conversions, as allowed by the language, can lead to errors creeping in the program if care is not taken. Thus, explicit type conversions may be used

Stack, write c language program that shows stack overflow..

write c language program that shows stack overflow..

Need help, how to make basics strong and best logic skills what are the bes...

how to make basics strong and best logic skills what are the best way to be a expert programmer ? what counts a lot knowledge or practice?

Static optimality theorem, Question 1 Describe the following with respect ...

Question 1 Describe the following with respect to pointers in C language- Pointers and Arrays Usage of Pointers in functions Write programs in C to demonstrate the

Pointers, In this sub-task will you implement three functions for the final...

In this sub-task will you implement three functions for the final three function prototypes that will do exactly the same as the three functions that you have just written. This ti

C language, WHAT IS A C LANGUAGE? C IS A PROGRAMMING?

WHAT IS A C LANGUAGE? C IS A PROGRAMMING?

Pointer declaration for member function, P o i n t e r d...

P o i n t e r d e c l a r a t i o n f o r me m b e r f un c t i o n : M e t h o d 1 : W h e n C l a ss i s n o t

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