On Dec 30, 9:27*am, "subramanian10...@yahoo.com, India"
<subramanian10...@yahoo.com> wrote:
> Suppose 'Test' is a class.
>
> Suppose I create an instance 'obj' of the 'Test' class:
>
> Test obj;
>
> Now, suppose I write
>
> Test another = obj;
>
> My question: is this last line called 'direct -initialization' or
> 'copy-initialization' ?
>
> Kindly clarify.
>
> Thanks
> V.Subramanian
Hi
I am sorry for some inaccuracy. My answer is not incorrect in general,
but I read the
C++ standard draft ISO/IEC JTC 1/SC 22 N 4411 and I found the
following statements:
The initialization that occurs in the form
T x = a;
as well as in argument passing, function return, throwing an
exception, handling an exception,
and aggregate member initialization is called copy-initialization.
The initialization that occurs in in the forms
T x(a);
T x{a};
as well as in new expressions, static_cast expressions, functional
notation type conversions, and base and
member initializers is called direct-initialization.
So I think the statement:
Test another = obj;
should be copy-initialization.
Cheers,
Saeed Amrollahi
|