Can you guess why the following program fails to compile due to an error in the call to equals from within main? Bonus points if you don't build it.
struct data {Tip: If you make base
int field;
};
template< typename Data >
class base {
public:
virtual ~base(void)
{
}
virtual bool equals(const Data& a,
const Data& b) const
{
return a == b;
}
};
class child : public base< data > {
public:
bool equals(const data& a,
const data& b) const
{
return a.field == b.field;
}
};
int
main(void)
{
data d1, d2;
base< data >* c = new child();
(void)c->equals(d1, d2);
delete c;
return 0;
}