What is this crazy C++11 syntax ==> struct : bar {} foo {};?

后端 未结 2 481
感动是毒
感动是毒 2020-12-07 07:17

What could this possibly mean in C++11?

struct : bar {} foo {};
2条回答
  •  囚心锁ツ
    2020-12-07 07:26

    This defines:

    • an anonymous struct,
    • which is derived publicly from bar
    • which (anonymously) defines nothing else but what it derived from bar
    • and finally, an instance, called "foo" is created,
    • with an empty initializer list

    struct : bar {} foo {};
    

提交回复
热议问题