This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/eo/test/t-eofitness.cpp
1999-09-10 12:03:51 +00:00

77 lines
1.7 KiB
C++

//-----------------------------------------------------------------------------
// t-eofitness.cpp
// (c) GeNeura Team 1998
//-----------------------------------------------------------------------------
#include <iostream> // cout
#include <eo> // eoFitness
//-----------------------------------------------------------------------------
class eoFloat: public eoFitness
{
public:
bool operator<(const eoFitness& other) const
{
const eoFloat& x = (const eoFloat&) other;
return fitness < x.fitness;
}
operator float() const
{
return fitness;
}
void printOn(ostream& os) const
{
os << fitness;
}
void readFrom(istream& is)
{
is >> fitness;
}
private:
float fitness;
};
//-----------------------------------------------------------------------------
main()
{
eoFloat a, b;
unsigned repeat = 2;
while (repeat--)
{
cout << "------------------------------------------------------" << endl;
cout << "testing < ";
if (a < b)
cout << a << " < " << b << " is true" << endl;
else
cout << a << " < " << b << " is false" <<endl;
cout << "testing > ";
if (a > b)
cout << a << " > " << b << " is true" << endl;
else
cout << a << " > " << b << " is false" <<endl;
cout << "testing == ";
if (a == b)
cout << a << " == " << b << " is true" << endl;
else
cout << a << " == " << b << " is false" <<endl;
cout << "testing != ";
if (a != b)
cout << a << " != " << b << " is true" << endl;
else
cout << a << " != " << b << " is false" <<endl;
a = b;
}
}
//-----------------------------------------------------------------------------