Class with delegating constructors
class A {
A(SomeObject obj,
int x,
const string& y
) {
A(SomeObject obj, const string& y)
:A(obj, 0, y) {}
};
Intended use:
SomeObject obj;
A a1(obj, "first");
A a2(obj, "second");
The construction is to build SomeObject
exactly once when the construction is performed A
. Will it pass obj
to create a copy SomeObject
when delegating to another constructor? If so, how can I avoid this?
source
share