Polymorphism question

I have some operator <</>> overloads like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
class player : public animate {
//...
    friend ostream& operator << (ostream&, const player&);
    friend istream& operator >> (istream&, player&);
//...
}

class animate {
//...
    friend ostream& operator << (ostream&, const animate&);
    friend istream& operator >> (istream&, animate&);
//...
}


Inside of friend istream& operator >> (istream& file, player& Player) I want to call the animate version to have in fill in the animate members. I tried:

file>>(static_cast <animate&> (Player));

But that did not actually modify Player like I need it to. Is there a way to do this or do I need to just define one for the player class and update it whenever I change anything in the animate class?
Last edited on
That should have worked... what did it do?
Nvm, it was a (another) dumb mistake I made...I put it in a position where it wasn't able to load all of the stuff from the file (because of the ordering), and it also prevented player from loading some of it's stuff...
Last edited on
Topic archived. No new replies allowed.