我可以在调用另一个构造函数之前做一些处理吗?

C++ : can I do some processing before calling another constructor?

本文关键字:处理 调用 另一个 构造函数 我可以      更新时间:2023-10-16

我有一个有两个构造函数的类。

class Foo {
  Foo(B b) {... }
  Foo(int n) : Foo(buildBFromInt(n)) {} ??
}

第一个接受某个对象,我想要第二个,它首先从一个更简单的类型创建对象。

从c++ 11开始是可能的。