#ifndef _MYDATA1_H #define _MYDATA1_H #include "apstring.h" #include "position1.h" // #include // Not needed for CodeWarrior IDE 4.0 or later // mydata1.h // 1.31.01 // G. Volger // Header file for string with numerical data class class MyData { public: // Constructors MyData(); MyData(apstring name, Position value); // Accessors void Print(ostream & out) const; // Mutators void Input(istream & in); // Realtional operator overloading functions bool Equal(const MyData & rhs) const; bool Less(const MyData & rhs) const; private: apstring myName; Position myPosition; }; // Free functions ostream & operator << (ostream & os, const MyData r); istream & operator >> (istream & is, MyData & r); bool operator < (const MyData & left, const MyData & right); bool operator == (const MyData & left, const MyData & right); bool operator <= (const MyData & left, const MyData & right); #endif /* MyData() // post: Default constructor, set value to zero and string to empty // Use a constructor initialzation list MyData(apstring name, Position value) // post: set values to intialized state using and initalization list // Use a constructor initialzation list void Print(ostream & out) const // pre: out is open and ready to use // post: MyData object is sent to out ostream // Only myName is sent to the out ostream, // myValue is ignored void Input(istream & in) // pre: in is open and ready to use // post: an object is read from the in istream in the form // Prompt: "Name: ", then myName value is read from in // Prompt: "Values ", then myPosition value is read from in bool Equal(const MyData & rhs) const // pre: current object & rhs are initialized // post: returns (*this) == rhs bool Less(const MyData & rhs) const // pre: current object & rhs are initialized // post: returns (*this) < rhs *** FREE FUNCTIONS *** bool operator < (const MyData & left, const MyData & right) // post: returns true if value Position fields are less than bool operator == (const MyData & left, const MyData & right) // post: returns true if value Position fields are equal bool operator <= (const MyData & left, const MyData & right) // post: returns true if value Position fields are less than or equal to ostream & operator << (ostream & os, const MyData r) // Post: insert r onto "os", returns "os" (for chaining) istream & operator >> (istream & is, MyData & r) // post: extracts from "is" and places values in r, returns "is" for chaining */