#include #include #include using std::cout; using std::endl; using std::string; //using namespace std; class Customer { private: string firstname; string lastname; int id; friend bool operator<(int i, Customer const& c); public: Customer(string first, string last, int ID);//constructor ~Customer(); //destructor string getName(); int getID() const{ return id; }; void SetName(string first, string second); bool operator<(Customer const& c) const; bool operator<(int i) const; }; bool operator<(int i, Customer const& c); Customer::Customer(string first, string last, int ID) { //cout << "Constructing the object with id " << ID << endl; firstname = first; lastname = last; id = ID; } Customer::~Customer() { //cout << "Destructing the object with id " << id << endl; } string Customer::getName() { return firstname + " " + lastname; } void Customer::SetName(string first, string last) { firstname = first; lastname = last; } bool Customer::operator<(Customer const& c) const { return id < c.getID(); } bool Customer::operator<(int i) const { return id < i; } bool operator<(int i, Customer const& c) { return i < c.id; } class Account : public Customer { private: string acctype; public: Account(string first, string last, int ID, string tp) : Customer(first, last, ID), acctype(tp) { cout << "Constructing Bank Account of type " << acctype << endl; } ~Account() { cout << "Distructing Bank Account of type " << acctype << endl; } }; template T max(T const& t1, T const& t2) { return t1 < t2 ? t2 : t1; } template class Latest { private: T latest; public: Latest(T const& start):latest(start) {}; void add(T const& t) { latest = max(latest, t); } T GetLatest() { return latest; } }; template<> class Latest { private: int latest; public: Latest(int const& start) :latest(start) {}; void add(Customer const& t) { latest = max(latest, t.getID()); } int GetLatest() { return latest; } }; int addtwo(int & i) { return i + 2; } int main() { int i = 3; int const ci = 3; i = 4; //ci = 5; int& ri = i; ri = 5; int const & cri = ci; //cri = 5; int j = addtwo(i); Customer c1("Kate", "May", 142); Customer const c2("John", "Smith", 12); //c2.SetName("John", "Smith2"); //c2.getName(); return 0; }