Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TSKGunGun/5e75be9407c00ec92c6d to your computer and use it in GitHub Desktop.
Save TSKGunGun/5e75be9407c00ec92c6d to your computer and use it in GitHub Desktop.
オーバーライドを防ぐ仕組み
//VisualStudio2010で確認
#include "stdafx.h"
class CHoge
{
public:
CHoge(){}
protected:
virtual void Func() sealed { int i = 0; } ;
};
class CHogeHoge:CHoge
{
protected:
virtual void Func() { int i2 = 0; };
}
@TSKGunGun
Copy link
Author

VisualCだけの言語拡張。MsBuild以外のコンパイラだとエラーになると思われる。
C++11でこれに相当するとおもわれるfinalキーワードがある

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment