#include <iostream>

using namespace std;

class Base{
    int data;
public:
    Base(int di = 3): data(di){}
    virtual int compareTo(const Base& rhs) const;
};

class Derived: public Base{
public:
    int fake;
    Derived(int dataIn = 7, int fakeIn = 7):
	Base(dataIn),
	//data(dataIn),
	fake(fakeIn)
    {}
    virtual int compareTo(const Base& rhs) const;
};

/*
 * Returns 0 when equal, positive when this is greater, negative if
 * rhs is greater
 */
int Base::compareTo(const Base& rhs) const {
    cout << "base compare\n";
    return data - rhs.data;
}

int Derived::compareTo(const Base& rhs) const {
    cout << "Derived compare, fake is " << fake <<endl;
    return data - rhs.data;
}

int main(){

    Base b;
    b.data = 5;
    cout << b.compareTo(b) << endl;

    Derived d;
    d.data = 6;
    
    cout << d.compareTo(d) << endl;

    Base * bp = new Derived;
    cout << bp->compareTo(d) << endl;

    return 0;
}

