C++ anonymous class initialization

2020-08-10 07:13发布

问题:

is it possible to initialize member variables in anonymous class?

for example

class {
public: int &value;
} container;

回答1:

int x = 3;
class {
    public: int &value;
} container = {x};


标签: c++