+ 2

Query on decorator pattern

Hi Refer below code: I know I have implemented inheritance for one class nd other as decorator method.. I am getting confused with this. How decorator allows loose coupling compared to inheritance? In decorator method also, we have class pointer as data member of class. Also in main function, what is makes a big difference to the new object creation of decorator class compared to passing a plain juice object to other decorator class? Any reason of choosing decorator ? https://code.sololearn.com/cHF6OwBIUHZ8/?ref=app

8th May 2021, 5:55 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 ответ
0
Decorators are useful when grouping functionality of MULTIPLE classes. Instead of overriding all the functions of the base class oh, you redirect do functionalities to another class using a pointer to function. This is good your program has multiple classes Implement simple functionalities
14th May 2021, 3:01 PM
bernborgess
bernborgess - avatar