什么是这个疯狂的C ++ 11语法==> struct:bar {} foo {};?
这在C ++ 11中可能意味着什么?
struct : bar {} foo {}; 首先,我们将采用一个标准的抽象UDT(用户定义types):
 struct foo { virtual void f() = 0; }; // normal abstract type foo obj; // error: cannot declare variable 'obj' to be of abstract type 'foo' 
让我们回顾一下,我们可以在定义UDT的同时实例化UDT:
 struct foo { foo() { cout << "!"; } }; // just a definition struct foo { foo() { cout << "!"; } } instance; // so much more // Output: "!" 
让我们结合这些例子,回想一下,我们可以定义一个没有名字的UDT:
 struct { virtual void f() = 0; } instance; // unnamed abstract type // error: cannot declare variable 'instance' to be of abstract type '<anonymous struct>' 
 我们不再需要关于匿名UDT的certificate,所以我们可能会失去纯虚函数。 另外重命名instance为foo ,我们留下了: 
 struct {} foo; 
越来越接近。
那么,如果这个匿名的UDT是从一些基地派生的呢?
 struct bar {}; // base UDT struct : bar {} foo; // anonymous derived UDT, and instance thereof 
最后,C ++ 11引入了扩展的初始化程序 ,这样我们可以混淆如下的东西:
 int x{0}; 
和这个:
 int x{}; 
最后,这个:
 struct : bar {} foo {}; 
这是一个来自bar的未命名结构,实例化为具有空白初始值设定项的foo。
这定义了:
- 一个匿名结构,
-  这是从bar公开获得的
-   ( anonymously)除了从bar派生出来以外没有其他的定义
- 最后创build一个名为“foo”的实例,
- 有一个空的初始化列表
 struct : bar {} foo {};