V
Vincent ROGER
I have a maybe a "noob" question to ask but I'd like to why that code does
not compile and why more precisely it does not search for 'print()' method
in 'Model'.
Of course I could replace 'print()' by 'write()' but I'm stubborn.
Thanks for any help.
not compile and why more precisely it does not search for 'print()' method
in 'Model'.
Of course I could replace 'print()' by 'write()' but I'm stubborn.
#include <iostream>
using namespace std;
struct Model {
virtual void print(ostream &o)=0;
void print() { print(cout); }
};
struct Subclass : public Model {
void print(ostream& o)
{
o << "Subclass";
}
};
int main()
{
Subclass c;
c.print();
}
Thanks for any help.