I\'m in the proccess of learning the language and this is a noob doubt.
Is it possible to use a virtual friend function? I don\'t know if it\'s possible, I didn\'t
You can solve this without friend functions, using public virtual methods only:
struct BaseClass {
  virtual void print(std::ostream& os) const;
};
struct DerivedClass {
  virtual void print(std::ostream& os) const;
};
std::ostream& operator<<(std::ostream& os, const BaseClass& obj) {
  obj.print(os);
  return os;
}
If it doesn't make sense for the print method to be public, then the ostream& operator<< can be declared as friend.