fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct base {
  5. static void talk() { cout << "hello" << endl; }
  6. };
  7.  
  8. struct derived : public base {
  9. static void talk() { cout << "goodbye" << endl; }
  10. };
  11.  
  12. struct derived2 : public base {
  13. };
  14.  
  15.  
  16. int main() {
  17. base::talk();
  18. derived::talk();
  19. derived2::talk();
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
hello
goodbye
hello