Skip to content

Instantly share code, notes, and snippets.

@alvesjnr
Created July 19, 2011 20:23
Show Gist options
  • Save alvesjnr/1093613 to your computer and use it in GitHub Desktop.
Save alvesjnr/1093613 to your computer and use it in GitHub Desktop.
#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