fork download
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class Student {
  6. public:
  7. void study() {
  8. cout << "Student is studying\n";
  9. }
  10. };
  11.  
  12. class Teacher {
  13. public:
  14. void teach(Student& s) {
  15. cout << "Teacher is teaching\n";
  16. s.study();
  17. }
  18. };
  19.  
  20. int main() {
  21. Student s;
  22. Teacher t;
  23.  
  24. t.teach(s);
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Teacher is teaching
Student is studying