Reputation: 2127
I have a class with two constructors.
class Foo {
Foo(B b) {... }
Foo(int n) : Foo(buildBFromInt(n)) {} ??
}
The first takes some object and I would like to have a second one that first creates the object from a simpler type. Is this possible ?
Upvotes: 2
Views: 256
Reputation: 217438
It is possible since C++11. it is the delegating constructor, and you use the correct syntax.
Upvotes: 8