I actually didn't know how to call that thread... Take a look at that code:
class Base
{
public:
int a, b, c;
public:
friend istream & operator >> (istream &_istream, Base &base);
};
istream & operator >> (istream &_istream, Base &base)
{
_istream >> base.a;
_istream >> base.b;
_istream >> base.c;
return _istream;
}
class Derivative: public Base
{
public:
int d;
public:
friend istream & operator >> (istream &_istream, Derivative &derivative);
};
istream & operator >> (istream &_istream, Derivative &derivative)
{
_istream >> (Base)derivative; // something's wrong
_istream >> derivative.d;
return _istream;
}
I just want to make a "shortcut" and assign a, b and c with the function called in line of interest (the one with comment "some's wrong"). However, it just doesn't work. I could do something like:
istream & operator >> (istream &_istream, Derivative &derivative)
{
_istream >> derivative.a;
_istream >> derivative.b;
_istream >> derivative.c;
_istream >> derivative.d;
return _istream;
}
But this is only a code duplication which I want to avoid.