All pastes #106734 Raw Edit

Something

public cpp v1 · immutable
#106734 ·published 2006-07-30 14:53 UTC
rendered paste body
#include <iostream>#include <math.h>#include <string.h>using namespace std;class Foo {protected:    char *foo;public:    Foo() {        foo = NULL;    }    Foo(char *str) {        foo = new char[100];        strcpy(foo, (str) ? str : "");    }    virtual ~Foo() {        if (foo) {            delete [] foo;        }    }    void* data() {        return foo;    }    int display() {        cout << foo << endl;    }};class Bar: public Foo {public:    Bar(char c) {        foo = new char;        *foo = c;    }    ~Bar();};int main(void) {    Foo one("this is a foo ");    Bar two('F');    one.display();    two.display();    return 0;}bhearsum@gaz:~/tmp$ gcc -lstdc++ -o test test.cpp/tmp/ccZ3rM8T.o: In function `main':test.cpp:(.text+0x67): undefined reference to `Bar::~Bar()':test.cpp:(.text+0x7a): undefined reference to `Bar::~Bar()'/tmp/ccZ3rM8T.o: In function `Bar::Bar(char)':test.cpp:(.gnu.linkonce.t._ZN3BarC1Ec[Bar::Bar(char)]+0x19): undefined reference to `vtable for Bar'collect2: ld returned 1 exit status