[ Post New Message | Post Reply to this One | Send Private Email to Mike Mannakee | Help ]

Using new with user-defined objects

from Mike Mannakee (B3FEETBACK@AOL.com)
Then in the default constructor for the StockItem class, in the member initialization list you have:

m_worker(new UndatedStockItem)

where I would have expected to see (new UndatedStockItem()) to invoke the default constructor for that class. Is the 'no arguments' () syntax unnecessary when you're allocating memory via new? I guess that new just needs to know what type of variable it's being asked to allocate memory for. Is this right? And would putting the "()" in there cause an error, or is this a matter of preference?

(posted 9091 days ago)

[ Previous | Next ]