Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <iostream>
  2.  
  3. class Base
  4. {
  5. public:
  6.         int value;
  7.         virtual int get_value_plus_one();
  8. };
  9.  
  10. class Derived: public Base
  11. {
  12. public:
  13.         int get_value_plus_one()
  14.         {
  15.                 return value + 1;
  16.         }
  17. };
  18.  
  19. int main(){
  20.  
  21.         Derived d = Derived();
  22.         d.value = 10;
  23.         std::cout << d.get_value_plus_one() << std::endl;
  24. }
  25. /**
  26. Compiler output:
  27. /tmp/ccKnu9aW.o: In function `Base::Base()':
  28. test.cpp:(.text._ZN4BaseC2Ev[_ZN4BaseC5Ev]+0x8): undefined reference to `vtable for Base'
  29. /tmp/ccKnu9aW.o:(.rodata._ZTI7Derived[typeinfo for Derived]+0x8): undefined reference to `typeinfo for Base'
  30. **/