fork(4) download
  1. #include <iostream>
  2.  
  3. class Super {
  4. public: virtual void print() const {
  5. std::cout << __PRETTY_FUNCTION__ << std::endl;
  6. }
  7. public: virtual ~Super() {}
  8. };
  9.  
  10. class Sub : public Super {
  11. public: virtual void print() const {
  12. std::cout << __PRETTY_FUNCTION__ << std::endl;
  13. }
  14. };
  15.  
  16. int main() {
  17. Super *obj = new Sub();
  18. // how to call 'Super::print()' from 'obj'
  19. // without using operator '.' and/or '->'?
  20. delete obj;
  21. }
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty