Hanry3 / projects

0 stars 1 forks source link

Update cpp.2cpp #8

Closed shbhmexe closed 4 hours ago

shbhmexe commented 4 hours ago

**1. Abstract Class (Operation): The Operation class has a pure virtual function execute, making it an abstract class. Derived classes like Add, Subtract, Multiply, and Divide implement this function.

  1. Factory Pattern: The OperationFactory class contains a method getOperation() which returns the appropriate operation object based on the user input.
  2. Error Handling: If division by zero is attempted, an exception is thrown to prevent invalid operations.**