假设以下构造函数:

class Needed
{
public:
    Needed () {}
    Needed (const char *name) {}
};


class Dummy
{
public:
    Dummy (): needed ( "Jimmy" ) {}

private:
    Needed needed;
};

那么,我在这里两次初始化了needed吗?

最佳答案

不,您只能在 Member Initializer List 中初始化一次。

10-04 11:26