这是假设的,但我有一个带有两个重载构造函数的类 - 其中没有一个是默认的构造函数。如果我从另一个调用一个构造函数,它会递归吗?例如:
class Example
{
Example(const int integer)
{
//Constructor Code Here
}
Example(argument)
{
Example object(68);
//Rest of constructor code
}
};
答案 0 :(得分:5)
递归是指函数调用本身,而不是具有不同参数的同名重载函数。你所描述的根本不是递归。它是delegating constructors,是C ++ 11中引入的新功能。根据定义:“委托构造函数不能递归”。