Top 5

Benji Smith dlanguage at benjismith.net
Fri Oct 10 09:04:35 PDT 2008


KennyTM~ wrote:
> I think... “new S” creating a struct pointer while “new C” creating a 
> class object reference is confusing enough...

The rule I'd like to see in place would be something like this:

"To create an instance of a type, you always use the 'new' keyword. The 
value returned by 'new' depends on the type of instance you're creating. 
For structs, it's a pointer and for classes it's a reference. Since 
arrays are (or should be) objects, 'new' returns a reference to the 
resultant array object."

Easy peasey, lemon-squeezey :-)

--benji



More information about the Digitalmars-d mailing list