Re: Simple const-related question
On Feb 19, 2:05 am, Jeff Schwab <j...@schwabcenter.com> wrote:
[...]
MyObject* p1 = myFunction(); // p1 is non-const
const MyObject *p2 = myFunction(); // p2 is ???
Get out of the Java habit of putting () after the class name when
calling new. I'm pretty sure that "new Object();"
Allocates a default-constructed Object.
and "new Object;" do
Allocates a potentially uninitialized object, if Object is a POD type.
http://www.research.att.com/~bs/bs_faq2.html#malloc
I don't usually use the parentheses, either, but I guess I
probably should.
I don't usually use them either, because I learned C++ before
this distinction existed. But then, I don't usually dynamically
allocate objects which don't have a user defined constructor, so
it doesn't make a difference.
I also don't usually allocate objects directly with new.
What do you allocate them with, then?
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34