fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A() {};
  8. void talk() { speak(); };
  9. // void speak(){
  10. // cout << "I am A\n";
  11. // }
  12. };
  13.  
  14. class B: public A
  15. {
  16. public:
  17. B() {};
  18. void speak(){
  19.  
  20. cout << "I am B\n";
  21. };
  22. //using A::talk;
  23. };
  24.  
  25. B example;
  26.  
  27. int main() {
  28. // your code goes here
  29. example.speak();
  30. example.talk();
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 3140KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function 'void A::talk()':
prog.cpp:8:22: error: 'speak' was not declared in this scope
  void talk() { speak(); };
                      ^
stdout
Standard output is empty