为什么在设置类组合时,可以使用默认构造函数调用包含的类,但不能使用带参数的类调用?
那有点令人困惑; 让我举一个例子.
#include "A.h"
class B
{
private:
A legal; // this kind of composition is allowed
A illegal(2,2); // this kind is not.
};
Run Code Online (Sandbox Code Playgroud)
假设存在默认构造函数和存在2个整数的构造函数,则只允许其中一个.为什么是这样?
c++ ×1