constructor question

what is the difference between this
Something::Something(obj& newO) : O(newO){}
also what do you called it when you do this^

and this

Something::Something(obj& newO){ O = newO }

In the first case, O is constructed with the parameter newO.

In the second case, O is default-constructed then newO is assigned to it.

Generally the first is preferred as it has less actions associated with it, and in fact is the only way to do it if O didn't happen to have a default constructor.
Wouldn't O need a convert constructor or something for that to work?
Last edited on
anyone know the name of the first case i presented so i can look it up ?
It is named ctor-initializer.
Topic archived. No new replies allowed.