delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/20/19:49:26

From: "James S. Adelman" <j DOT adelman AT ukonline DOT co DOT uk>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
Subject: Re: Making C++ little easier to beginners...
Followup-To: comp.lang.c++
Date: Sat, 20 Oct 2001 21:46:19 +0100
Organization: --
Lines: 38
Message-ID: <1866468.8dNRCrzyxZ@tversky.2y.net>
References: <9qmkrh$581$1 AT tron DOT sci DOT fi>
NNTP-Posting-Host: ts134050.dial.liv.ac.uk
Mime-Version: 1.0
X-Trace: news.liv.ac.uk 1003620356 27532 138.253.134.50 (20 Oct 2001 23:25:56 GMT)
X-Complaints-To: abuse AT liverpool DOT ac DOT uk
NNTP-Posting-Date: 20 Oct 2001 23:25:56 GMT
User-Agent: KNode/0.6.1
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id f9KNj4F09157
Reply-To: djgpp AT delorie DOT com

Traveler wrote:

> Little example...
> 
> int    x = 10,
>         y = 10;
> 
> if(x == 10 && x == 10)        // Does this look scary or weird to you ?
>     cout << "true\n";
> else
>     cout << "false\n";
> 
> 
> wouldn´t this be nicer ?
> 
> if(x EQUAL 10 AND y EQUAL 10)
>     cout << "true\n";
> else
>     cout << "false\n";

Hell, no.  Just wait until someone asks you why:

if(x AND y EQUAL 10) 
    cout<<"true";
    cout<<"\n";
else
    cout<<"false\n";

doesn't work.

cout<<(10==x&&10==y)?"true":"false"<<endl;

is still the sensible way to write this code.
-- 
James S. Adelman
Liverpool

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019