2

Consider the following class:

class X {
};

One can easily inherit from this:

class Y : public X {
};

Okay so far... Let's say we don't want anyone to inherit from Y we can then do this instead.

class Y sealed : public X {
};

Or we could do this:

class Y final : public X 
};

What are the main differences between the two keywords final and sealed? I know their basic purposes and what they are used for; I just wanted to know if there was anything specifically different between the two.

Francis Cugler
  • 7,788
  • 2
  • 28
  • 59

1 Answers1

7

sealed is not Standard C++ - it appears to be a Visual C++ CX extension. From that same page:

The ISO C++11 Standard language has the final keyword, which is supported in Visual Studio. Use final on standard classes, and sealed on ref classes.

Vittorio Romeo
  • 90,666
  • 33
  • 258
  • 416
  • Thank you for the information. Now I know that `final` is through the standard and `sealed` is MS specific, otherwise they do basically the same thing. – Francis Cugler Jun 23 '17 at 22:55