From: Anthony Yuen Newsgroups: comp.lang.c++,comp.os.msdos.djgpp Subject: Re: Making C++ little easier to beginners... Date: Thu, 18 Oct 2001 13:33:14 +0000 (UTC) Organization: ISINet, Nova Scotia Lines: 60 Message-ID: <9qmlmq$lou$1@News.Dal.Ca> References: <9qmkrh$581$1 AT tron DOT sci DOT fi> NNTP-Posting-Host: borg.cs.dal.ca Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: News.Dal.Ca 1003411994 22302 129.173.66.61 (18 Oct 2001 13:33:14 GMT) X-Complaints-To: postmaster AT Dal DOT Ca NNTP-Posting-Date: Thu, 18 Oct 2001 13:33:14 +0000 (UTC) User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (SunOS/5.6 (sun4u)) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com In comp.lang.c++ 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"; > No, not scary. Just buggy. Why compare x with 10 *twice*? > wouldnīt this be nicer ? > > if(x EQUAL 10 AND y EQUAL 10) > cout << "true\n"; > else > cout << "false\n"; > No. This doesn't look like C or C++. > Hereīs little helper... > > #define AND & > #define COMPLEMENT ~ > #define EQUAL == > #define EQU EQUAL > #define NOT ! > #define OR | > #define XOR ^ > If you do something like this in your programs, you're inventing your own language. Nobody (who understands C or C++) will be able to read your code. Not to mention *wrong*. > As you can see the things "AND" & "OR" defined here are "bit" operators > not "logical" operators. However, there really is no difference > becourse you can use these two just as easily in "if" statementīs as in > bit manipulation. > There are *huge* differences between logical and bitwise operators. Please read a good C++ book to understand the differences. > All calculations done in computer, from the simplest addition to the > most complex 3rd grade (or greater) root solving uses these operatorīs > and their compinations inside the microprocessor. Huh? What is it you're trying to say?