What is the difference between containment and delegation?



What is the difference between containment and delegation?..

Answer / Awadhesh Prasad Gaur

Containment is a relationship in which one object has a pointer or reference to another object, allowing the containing object to access and manipulate the contained object. Delegation, on the other hand, is a design pattern in which an object defers some of its responsibilities to another object, usually by forwarding method calls to that object. In containment, the contained object is part of the containing object's lifetime; in delegation, the delegate object is independent.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

What is a constant reference?

1 Answers  


How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?

1 Answers  


What is operators in c++?

1 Answers  


Does c++ have finally?

1 Answers  


Write a program that will count the number of digits in an input integer up to value MAX_VALUE (2147483647). Thus, for an input of 5837 the output should be 4 digits Make sure that your program works for the numbers 0, 1, and 10. For the number 0, the output should be 1 digit

2 Answers  


Write a c++ code that will calculate the roots of a quadratic equation a2+ bx+c=0 Hint: d = sqrt (b2-4ac), and the roots are: x1 = (€“b + d)/2a and x2 = (€“b €“ d)/2a (use sqrt function from cmath.h )?

0 Answers   Maxobiz,


What are the types of container classes?

1 Answers  


What is problem with Runtime type identification?

2 Answers  


Write a program which uses functions like strcmp(), strcpy()? etc

1 Answers  


What is polymorphism in c++? Explain with an example?

1 Answers  


Is c++ the best programming language?

1 Answers  


What is a unnitialised pointer?

1 Answers  


Categories