Dear All,
The attached project implements a Factory for two products.
The program expects an integer argument. If the argument is positive, the program creates Product 1, otherwise Product 2.
Before the program ends the Factory cleaning code is called. This deallocates the polymorphic pointer (to either Product 1 or Product 2).
My question is: Why is neither the finalizer for Product 1 nor Product 2 called?
For example, if I run the program with argument 20 I would expect to get in the console:
- Factory: Creating Product 1.
- Factory: Creation success.
- Product 1: Using.
- Product 1: Destroying.
- Factory: Destroying product success.
Instead the line in bold (Product 1: Destroying) is missing.
Am I doing something wrong?
Thank you for any suggestions.