fork(4) download
  1. #include <iostream>
  2.  
  3. struct Bird {
  4. virtual void sing() { std::cout << "tweet, tweet\n"; }
  5. };
  6.  
  7. struct Sparrow : Bird {
  8. void sing() { std::cout << "chirp, chirp\n"; }
  9. };
  10.  
  11. int main() {
  12. Sparrow sparrow;
  13. Bird& bird = sparrow;
  14. bird.sing();
  15. return 0;
  16. }
Success #stdin #stdout 0s 4432KB
stdin
Standard input is empty
stdout
chirp, chirp