Has “In class member initialization” feature made into C++11?

前端 未结 1 1883
时光说笑
时光说笑 2020-12-11 15:33

In class initialization feature, which allows to initialize normal members inside the class itself,

struct A {
  int a = 0; // error: ISO C++ forbids in-clas         


        
相关标签:
1条回答
  • 2020-12-11 16:20

    Yes, that is legal in C++0x. There is an example of this at N3290 §12.6.2/8:

    struct C {
        /* ... */
        int j = 5; // OK: j has the value 5
    };
    
    0 讨论(0)
提交回复
热议问题