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

Write a program in C++ for Fibonacci series

655


Describe the advantage of an external iterator.

612


What is the use of endl in c++ give an example?

608


What do you know about near, far and huge pointer?

592


Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);

614






Distinguish between new and malloc and delete and free().

571


Is it possible to provide special behavior for one instance of a template but not for other instances?

626


Which of the following is not a valid declaration for main() a) int main() b) int main(int argc, char *argv[]) c) They both work

601


Define the process of handling in case of destructor failure?

574


Is c++ the hardest language?

559


Which of the following is evaluated first: a) && b) || c) !

1799


Explain public, protected, private in c++?

563


What is a rooted hierarchy?

674


Can there be at least some solution to determine the number of arguments passed to a variable argument list function?

600


What are the advantages of using const reference arguments in a function?

611