jeudi 27 juin 2019

When to make a destructor defaulted using =default?

Although using =default for constructors is clear for me (i.e. forcing the compiler to create the default constructor while other ctors exist), I still cannot understand the difference between these two type of destructors:

  1. Those that use =default
  2. Those that are not defined explicitly and generated by compiler automatically.

The only thing that comes to my mind is that the group-1 destructors can be defined as virtual, but group-2 is always non-virtual. So, is that the only difference between them? Is there any scenarios that the compiler is not generating the destructor, but using =default forces the compiler to generate it?

p.s. I have checked lots of Qs in stackoverflow, but none of them answers my Q. Here are some relevant questions.

  1. Difference between =default and {} ctos/destructors
  2. Defaulting virtual destructors
  3. Difference between =default and empty dtrs

Aucun commentaire:

Enregistrer un commentaire