Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef OLYMPIAN
- #define OLYMPIAN
- #include <iostream>
- using namespace std;
- #include "LListIter.h"
- // A class for holding an Olympian
- // name and career medal total
- class Olympian {
- public:
- // constructor
- Olympian(string nam= "", int T= 0, int G= 0 ) :
- name(nam), total(T), gold(G) {};
- // get the name
- string getName() const { return name; }
- // get the total
- int getTotal() const { return total; }
- // get the number of golds
- int getGold() const { return gold; }
- // set the name
- void setName(string nam) { name= nam; }
- // get the total
- void setTotal(int num) { total= num; }
- // get the number of golds
- void setGold(int num) { gold= num; }
- // compare two Olympians by name (same name?)
- bool operator==(const Olympian &);
- // compare two Olympians by medal total (more medals?)
- bool operator>(const Olympian &);
- private:
- string name;
- int total;
- int gold;
- };
- // print out the name and the medal total
- ostream& operator<<(ostream &os, const Olympian &olist);
- Olympian iter(olist);
- if(!iter.end()) {
- do {
- os << " " << iter.getName();
- os << " " << iter.getTotal();
- os << " " << iter.getGold();
- }
- while(iter.next());
- }
- return os;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement