digitalmars.D.learn - Translating parts of WTL to D
- Lionello Lunesu (25/25) May 18 2006 How would you translate this class to D:
- Lionello Lunesu (18/18) May 18 2006 Try 2:
- Jarrett Billingsley (3/4) May 18 2006 Huh? How so?
- Lionello Lunesu (21/27) May 18 2006 Take somefunc for example. C++:
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
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
"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
Jarrett Billingsley wrote:"Lionello Lunesu" <lio lunesu.remove.com> wrote in message news:e4hiuv$1af1$1 digitaldaemon.com...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.but it's not quite as usable as the C++ version.Huh? How so?
May 18 2006