Topic: C++ seems to allow an implicit const-->non-const conversion under certain circumstances


Author: "Florin Neamtu" <neaflo@zappmobile.ro>
Date: Thu, 31 Aug 2006 11:55:18 CST
Raw View
The program is not valid C++ as the "this" pointer cannot be used in
the initializer list.
In the scope of the initializer list the object is not yet constructed
and any reference to it is invalid; such your code passes a pointer to
an unconstructed object and the result is undefined according to the
standard.

You should not use the this pointer until all construction of the
object has completed.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]