小编Inv*_*ulk的帖子

构造函数返回什么?

我的问题是构造函数返回了什么?这个问题与"构造函数的返回类型是什么?"没有什么不同.我在某处读过一个构造函数隐式返回一个完整的对象(即隐式返回类型是类的名称),但不应该明确指定.

struct empty{};

int main(){
   empty(); //creates a temporary and implicitly a constructor is called
}
Run Code Online (Sandbox Code Playgroud)

因此,根据我的解释,隐式返回类型应该是类的名称,在本例中empty.我的狂野解释是否正确?

c++ constructor return-type

10
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

constructor ×1

return-type ×1