Created
July 19, 2011 20:23
-
-
Save alvesjnr/1093613 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Base | |
{ | |
public: | |
int value; | |
virtual int get_value_plus_one(); | |
}; | |
class Derived: public Base | |
{ | |
public: | |
int get_value_plus_one() | |
{ | |
return value + 1; | |
} | |
}; | |
int main(){ | |
Derived d = Derived(); | |
d.value = 10; | |
std::cout << d.get_value_plus_one() << std::endl; | |
} | |
/** | |
Compiler output: | |
/tmp/ccKnu9aW.o: In function `Base::Base()': | |
test.cpp:(.text._ZN4BaseC2Ev[_ZN4BaseC5Ev]+0x8): undefined reference to `vtable for Base' | |
/tmp/ccKnu9aW.o:(.rodata._ZTI7Derived[typeinfo for Derived]+0x8): undefined reference to `typeinfo for Base' | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment