fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Person {
  6. public:
  7. friend istream& operator>>(istream& out, Person& obj);
  8. };
  9.  
  10. istream& operator>>(istream& out, Person& obj) {
  11. cout << "Person";
  12. }
  13.  
  14. class Student : public Person {
  15. public:
  16. friend istream& operator>>(istream& out, Student& obj);
  17. };
  18.  
  19. istream& operator>>(istream& out, Student& obj) {
  20. cout << "Student";
  21. }
  22.  
  23. int main() {
  24. Person a;
  25. cin >> a;
  26. Student b;
  27. cin >> b;
  28. }
  29.  
  30.  
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
PersonStudent