delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/17/18:01:46

From: juergen AT monocerus DOT demon DOT co DOT uk (Juergen Heinzl)
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp
Subject: Re: Points of view about Java...
Date: Sat, 17 Mar 2001 22:54:07 GMT
Organization: Rent A Bug Ltd
Message-ID: <slrn9b7qh1.kag.juergen@monocerus.demon.co.uk>
References: <990mc1$aqg$1 AT tron DOT sci DOT fi>
NNTP-Posting-Host: monocerus.demon.co.uk
X-NNTP-Posting-Host: monocerus.demon.co.uk:158.152.4.186
X-Trace: news.demon.co.uk 984869647 nnrp-01:25112 NO-IDENT monocerus.demon.co.uk:158.152.4.186
X-Complaints-To: abuse AT demon DOT net
User-Agent: slrn/0.9.5.7 (UNIX)
Lines: 56
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <990mc1$aqg$1 AT tron DOT sci DOT fi>, Traveler wrote:
>Hello
>
>(The following rubbish is quite long, so if you are in hurry skip this
>message...)
>
>Is there already a Number class in C++ standard ?
[-]
Nada.

>(I don't know becourse I have not read it. Or have I ?
>Was it a book  called "The C++ Programming Language",2nd edition ?....)
[-]
It's the 2nd edition of a book about "The C++ Programming Language" -- and
it's THE C++ book to start with.

>Anyway, here is the very bare bones (all the mathematical functions missing)
>for the Number class (that is, if somebody is interested...sight!).
[-]
Quite some things I didn't like declaring PI or ...

const   double                  Number<double>::MIN_VALUE = 2.22507e-308;

... which might be fine on your machine (CPU) but not mine, so see what ...

std::numeric_limits<double>::...

... has to offer instead.

Of course you ought to avoid things like these ...

// Overloaded operator that calculates the x raised to y power.
// Use recursion or loop...
Number<T>      operator^(double exp)
{
  // Your code comes here...
}

... since here you re-define the meaning of '^'. It's just one reason for
people to complain about operator overloading. Last but not least, where's
the beef ? Or what did I gain by using a number class ?

[-]
>First, I learned that Java did not use operator overloading. Not neato...
[-]
It does, sort of as after all what's the result of "this" + "that" given '+'
being an arithmetic operator ?

[-]

Ta',
Juergen

-- 
\ Real name     : Juergen Heinzl                \       no flames      /
 \ EMail Private : juergen AT monocerus DOT demon DOT co DOT uk \ send money instead /

- Raw text -


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