Constructor calling another constructor?

This is a discussion on Constructor calling another constructor? within the C++ Programming forums, part of the General Programming Boards category; I thought this was possible (and I don't see why it wouldn't be), but VC++ gives me a
error C2614: ...

You can call a constructor from a constructor, but not from an initializer, I don't think.

Base class constructors can be called in the initializer list of a derived class' constructor. Because copy constructors are also constructors, they can have an initializer list.

But copy constructors should call their members' copy constructors if possible. If that's not possible, that means that you have to do a deep copy of some pointer, probably. It would be better to use a smart pointer based on whatever your needs may be, due to the fact that smart pointers are easy to reassign and handle their own object.

There's one ugly way to do it if you have to use a raw pointer. From memory:

Because, if common code was required in two or more constructors, a member function could be defined and called by both constructors. Delegating constructors are therefore technically unnecessary, and were viewed as an unnecessary feature by the standard committee. The original proposal for delegating constructors also did not define what was required particularly well (the syntax was essentially what is put forward now, but the actual semantics were poorly defined). The combination of a technically unnecessary feature being the subject of a poorly defined technical proposal led to rejection.

More importantly, a delegated-to constructor can have an initializer list of its own, whereas a member function cannot.
Which is why the feature will be there in 09.
I think the restriction is something like: the initializer list may contain a delegation to another constructor of the same class or a list of base and member initializers, but not both. This is necessary to ensure sane semantics.

I think the restriction is something like: the initializer list may contain a delegation to another constructor of the same class or a list of base and member initializers, but not both. This is necessary to ensure sane semantics.

Sounds good. I kind of liked the constructor chaining thing in Java, though part of its added usefulness was due to the lack of default arguments as a language feature.

I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.