C++0xの新機能の一つ「explicit 変換演算子」。
暗黙の型変換を禁止します。
class TFoo
{
public:
TFoo(int i) {};
};
class TBar
{
public:
explicit TBar(int i) {}; //暗黙の型変換を禁止
};
int _tmain(int argc, _TCHAR* argv[])
{
TFoo foo = 1;
TBar bar = 1; //ここでコンパイルエラー
エラーメッセージ
[BCC32 エラー] File1.cpp(25): E2034 'int' 型は 'TBar' 型に変換できない