4

是否可以定义为聚合private聚合初始化?我希望该类只能由其自己的静态私有成员聚合初始化。

例子:

struct Size
{
    const unsigned int width;
    const unsigned int height;

    static const Size big;
    static const Size small;

private:

    Size( ) = default;

    // something to declare the aggregare initialization as private
};

const Size Size::big = { 480, 240 };
const Size Size::small = { 210, 170 };
4

0 回答 0