S
sasha
class Base{
public:
std:stream& operator<<( std:stream& os, const string &str )
{ return print(os); }
void print(stdstream& os){ os<<"Base\n";}
};
class Derived{
public:
using Base:perator<<;
void print(stdstream& os){ os<<"Derived\n";}
};
D d=Derived;
D<<"str";
B & pd=new Derived;
pd<<"str";
Notice that that print is not a virtual function.
I wonder if you bring base class member in the Derive class scope
and invoke it via Derived object, which print is it going to call: one
from derived or one from base.
public:
std:stream& operator<<( std:stream& os, const string &str )
{ return print(os); }
void print(stdstream& os){ os<<"Base\n";}
};
class Derived{
public:
using Base:perator<<;
void print(stdstream& os){ os<<"Derived\n";}
};
D d=Derived;
D<<"str";
B & pd=new Derived;
pd<<"str";
Notice that that print is not a virtual function.
I wonder if you bring base class member in the Derive class scope
and invoke it via Derived object, which print is it going to call: one
from derived or one from base.