In a class, there is a reference or pointer of an object of
another class embedded, and the memory is either allocated
or assigned to the new object created for this class. In
the constructor, parameters are passed to initialize the
data members and the embedded object reference to get
inialized. What measures or design change should be advised
for proper destruction and avioding memory leaks, getting
pointers dangling for the embedded object memory
allocation? Please suggest.

Answer Posted / shanthila

use copy constructors

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?

697


What methods can be overridden in java?

758


Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?

1831


How can you link a c program with a c function?

648


What is the full form of stl in c++?

786






What is a sequence in c++?

661


How should runtime errors be handled in c++?

714


Give example of a pure virtual function in c++?

689


Explain bubble sorting.

725


What is the protected keyword used for?

725


What is the correct syntax for inheritance a) class aclass : public superclass b) class aclass inherit superclass c) class aclass <-superclass

790


What is the v-ptr?

744


How did c++ get its name?

661


What are smart pointers?

778


What is the difference between delegation and implemented-in-terms-of?

632