
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.62 KB | hits: 11 | expires: Never
#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'
**/