Besides being just generally frightening, does this program contain any undefined, implementation-defined, or unspecified behavior? Or is it well defined?
the name of the original object .. can be used to manipulate the new object if ... the type of the original object does not contain any non-static data members whose type is .. a reference type
(but there are cases where new (this) Whatever; is well-defined)
@Cubbi. I read the C++ standard (2011-04-11) document. I am not getting why this case (class having reference type data member) is undefined, according to standard. Please explain. I checked this program with HP-UX g++ 4.7.0, HP-UX aCC and few online compilers like coliru, ideone.com. All of them give the same output as shown by L B.