home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,931 of 33,346   
   Dave Harris to DeMarcus   
   Re: Can I overload with unused arguments   
   14 Mar 13 04:32:40   
   
   From: brangdonj@googlemail.com   
      
   In article <513fa7e1$0$32111$14726298@news.sunsite.dk>,   
   use_my_alias_here_at_hotmail_com@tellus.orb.dotsrc.org (DeMarcus) wrote:   
   > Is it justifiable to introduce a NullEntertainer, instantiate it as   
   > NULL_ENTERTAINER and then overload watchShow() with a   
   > NullEntertainer argument that isn't used, just to make the code   
   > slightly more clear and explicit to read?   
      
   Yes. Although I wouldn't use all-capitals for a name which wasn't a   
   macro. I would probably use an enum rather than a class, which is   
   slightly lighter weight. For example, I have used:   
      
        enum Utf8_ { Utf8 };   
        enum Utf16_ { Utf16 };   
        enum Utf32_ { Utf32 };   
      
        StringUtf8 source( "sample" );   
        StringUtf16 destination( Utf8, source );   
      
   Here the first enum value isn't used, but the type is used to   
   statically resolve a conversion. It's redundant because the type of   
   source has the same information, but requiring it makes the conversion   
   more explicit. (In practice I'd give them different values in case   
   someone wanted to test or print them at run time.)   
      
   > Or are there better ways to solve this?   
      
   Sometimes renaming the function is clearer. Using the same function   
   name allows some (compile-time) polymorphism, but if you don't need it   
   then using a different function name makes the declarations cleaner   
   without adversely affecting the caller.   
      
        a.watchNullShow();   
      
   -- Dave Harris, Nottingham, UK.   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca