[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Use true/false or TRUE/FALSE in KDE C++ programs?
From:       Nicos Gollan <gtdev () spearhead ! de>
Date:       2005-05-29 15:25:50
Message-ID: 200505291725.54771.gtdev () spearhead ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Sunday May 29 2005 16:02, Richard Dale wrote:
> On Sunday 29 May 2005 16:48, André Wöbbeking wrote:
> > On Sunday 29 May 2005 15:36, Richard Dale wrote:
> > > I hate code which type puns ints into booleans such as:
> > >
> > > if !strcmp("mything", "myotherthing') {
> > > 	..other difficult to read crap code
> > > }
> >
> > this is a bad example as strcmp() returns a tristate: less, equal or
> > greater but I know what you mean.
>
> Well, it's a good example because it's so bad.. :)

You could write a very short, trivial  wrapper to map strcmp's output to an 
enumeration, so that it better suits your needs. However, with the string 
class in standard C++, you don't need that stuff anyway in most cases. You 
can just write it straightforward, thanks to overloaded operators:

#include <iostream>
#include <string>

using namespace std;

int main( void ) {
        string a( "Hello, world!" );

        if( a == "Hello, world!" )
                cout << "pass." << endl;

        exit(0);
}

-- 
Got Backup?

Jabber: Shadowdancer at jabber.fsinf.de

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic