Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Latest commit

 

History

History
30 lines (19 loc) · 1.06 KB

README.md

File metadata and controls

30 lines (19 loc) · 1.06 KB

Visitor Design Pattern

  • Allows to add methods to classes of different types without much altering of those classes.
  • You can make completely different methods depending on the class used.
  • Allows you to define external classes that can exten other classes without majorly editing them

we will be using shared_ptr for automatic memory management


In this example we will implementing different types of credit cards and calculate the cash back you get according to the offers from different credit cards

Amount of Cashback you get with different credit cards :

Offers Gold Silver Bronze
Gas 10% 2% 5%
Food 20% 3% 10%
Hotel 10% 2% 3%
Other 1% 5% 20%

References