home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
VSCPPv8.zip
/
VACPP
/
IBMCPP
/
samples
/
IOC
/
PLANETS
/
PLANET.H
< prev
next >
Wrap
Text File
|
1995-03-15
|
2KB
|
53 lines
/*************************************************************************
IBM C/C++ Tools Version 3.00 - Collection Class Library
(C) Copyright IBM Corporation 1992 ,1995, Licensed Program-Property of
IBM. All Rights Reserved. US Government Users Restricted Rights - Use,
duplication or disclosure restricted by GSA ADP Schedule Contract with
IBM Corp.
*************************************************************************/
/*-------------------------------------------------------------*\
| planet.h - Class Planet for use in our Sorted Set example |
\*-------------------------------------------------------------*/
class Planet {
private:
char* plname;
float dist;
float mass;
float bright;
public:
// Let's use the compiler generated default for
// the copy constructor
Planet(char* aname, float adist, float amass, float abright) :
plname(aname), dist(adist), mass(amass), bright(abright) {}
// For any Set we need to provide element equality.
IBoolean operator== (Planet const& aPlanet) const
{ return plname == aPlanet.plname; }
// For a Sorted Set we need to provide element comparision.
IBoolean operator< (Planet const& aPlanet) const
{ return dist < aPlanet.dist; }
char* name() { return plname; }
IBoolean isHeavy() { return (mass > 1.0); }
IBoolean isBright() { return (bright < 0.0); }
};
/*-------------------------------------------------------------*\
| Iterator |
\*-------------------------------------------------------------*/
#include <iostream.h>
class SayPlanetName : public IIterator<Planet> {
public:
virtual IBoolean applyTo(Planet& p)
{ cout << " " << p.name() << " "; return True;}
};