Why retain new ?

janderson askme at me.com
Mon Aug 6 22:31:04 PDT 2007


Alex Burton wrote:
 > Given that all classes are on the heap, why not replace the syntax :
 > CmdLin cl = new CmdLin(argc, argv);
 > with
 > CmdLin cl(argc,argv);
 > saving some typing and repetition.
 >
 > Only when casting to base class would you want to do :
 > CmdLinBase cl = CmdLin(argc,argv);

I agree its a PITA.

I wounder maybe you could write a template:

CmdLin cl = New(argc, argv);

of course you can do:

auto cl = new CmdLin(argc, argv);



More information about the Digitalmars-d mailing list