我以前从未见过它.我认为这是":: sample"的拼写错误,但是当我看到它实际编译时我很困惑.有人能帮我找到吗?我不认为这是一个goto标签.
void f() {
  class: sample {
    // there were some members declared here
  } x;
}
Ale*_* C. 80
它是一个未命名的类,冒号意味着它私下继承sample.看到它
class Foo : private sample
{
    // ...
};
Foo x;
Naw*_*waz 21
我认为这是定义一个源自的无名类sample.并且x是该未命名类的变量.
struct sample{ int i;};
sample f() 
{
  struct : sample 
  {
    // there were some members declared here
  } x;
  x.i = 10;
  return x;
}
int main() 
{
        sample s = f();
        cout << s.i << endl;
        return 0;
}
ideone上的示例代码:http://www.ideone.com/6Mj8x
PS:因为无障碍原因我改为class了struct!