www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Translating parts of WTL to D

reply Lionello Lunesu <lio lunesu.remove.com> writes:
How would you translate this class to D:

#class _U_MENUorID

#public:






#void testfunc( _U_MENUorID x = 0U ){}

The straightforward translation would be:

#class _U_MENUorID

#public:






#void testfunc( _U_MENUorID x = null ){}

but it's not quite as usable as the C++ version.

Any ideas?

L.
May 18 2006
next sibling parent Lionello Lunesu <lio lunesu.remove.com> writes:
Try 2:

#struct _U_MENUorID {












#void testfunc( _U_MENUorID x = _U_MENUorID(null) ){}

It'll be efficient (no new's, pass by val) but needs an explicit cast 
(for both the default value and every passed parameter).

L.
May 18 2006
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Lionello Lunesu" <lio lunesu.remove.com> wrote in message 
news:e4hiuv$1af1$1 digitaldaemon.com...

 but it's not quite as usable as the C++ version.
Huh? How so?
May 18 2006
parent Lionello Lunesu <lio lunesu.remove.com> writes:
Jarrett Billingsley wrote:
 "Lionello Lunesu" <lio lunesu.remove.com> wrote in message 
 news:e4hiuv$1af1$1 digitaldaemon.com...
 
 but it's not quite as usable as the C++ version.
Huh? How so?
Take somefunc for example. C++: #void testfunc( _U_MENUorID x = 0U ){ #void usage(){ with the 'straightforward' D conversion I need an extra check in the function. Also, I must create instances of the class first :( #void testfunc( _U_MENUorID x = null ){ #void usage(){ L.
May 18 2006