> On Fri, 20 May 2011 20:42:26 +0300, Sean Kelly <[email protected]> > > wrote: > > The compiler can translate this into a single construction (it does in > > C++), but I don't know that it's required to. > > If not, i don't know any other use for constructors, you can do the almost > same thing with a function. > > struct A { > } > > A construct() { > } > > void main() { > A a = construct(); > }
That wouldn't work with A a(args, to, constructor); Now, I personally never use that syntax and always use auto a = A(args, to, constructor); but you can't do the first form without a constructor, and even in the second form, you're making it clear that you're spefically constructing a value of that type as opposed to using a some random function which happens to produce that type. But ultimately, constructors are just special functions anyway. - Jonathan M Davis
