Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Finalization of an object produced by a factory.

$
0
0

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.

AttachmentSize
Downloadapplication/zipFactory-initial.zip3.33 KB

Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>