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 / som shekhar
If you are using the reference orpointer of other class as
an Aggregation (class own every thing, tight coupling) then
the destructor should take care of it, but if the reference
or pointer is taken as composition (class doesnt owwn the
pointer, loose coupling) then the class destructor should
not worry about that.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is c++ & why it is used?
Write a Program to find the largest of 4 no using macros.
Which programming language's unsatisfactory performance led to the discovery of c++?
Name the debugging methods that are used to solve problems?
What is vectorial capacity?
Define the process of handling in case of destructor failure?
Why is standard template library used?
Why is c++ still used?
What is using namespace std in c++?
How long will it take to learn programming?
What is the difference between interpreters and compilers?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---
How does com provide language transparency?
What is the basic of c++?
Is c++ the hardest programming language?