F
flamexx7
http://www.rafb.net/paste/results/V3TZeb28.html
In this code, why copy constructor is not called while returning object from
no_arg() . I was trying to find answer in C++ Standard. and there it's
written that
"Whenever a temporary class object is copied using a copy constructor, and
this object and the copy have the same cv-unqualified type, an
implementation is permitted to treat the original and the copy as two
different ways of referring to the same object and not perform a copy at
all, even if the class copy constructor or destructor have side effects"
I tried to changed object typeof y in function no_arg() to const, and still
copy constructor is not called. Can any one explain me, why does compiler
behaves to both objects differently while returning objects from no_arg()
and pass_arg() ?
In this code, why copy constructor is not called while returning object from
no_arg() . I was trying to find answer in C++ Standard. and there it's
written that
"Whenever a temporary class object is copied using a copy constructor, and
this object and the copy have the same cv-unqualified type, an
implementation is permitted to treat the original and the copy as two
different ways of referring to the same object and not perform a copy at
all, even if the class copy constructor or destructor have side effects"
I tried to changed object typeof y in function no_arg() to const, and still
copy constructor is not called. Can any one explain me, why does compiler
behaves to both objects differently while returning objects from no_arg()
and pass_arg() ?