c++ virtual function override problem


recently i write a c++ code and  have a problem with using virtual function

this is a code,

class Base {

publc :

    virtual ~Base() {}

    virtual void Set (void) = 0; // pure virutal fuunction


class Derived : public Base



    int m_nTest;

    virtual void Set (void) { m_nTest = 10; }


// make global object here !!

Derived gstDerived;

int main (void)


    Base * pstBase  = &gstDerived;

    pstBase->Set();  // -> this is a problem !!!!


if i am using normal function override instead virtual method override, perfectly fine,

but when i am using virtual function, looks like linker can not find overried function, (derived Set())

according to assembly code,

1. get gstDerived address

2.  get data by reference m_nTest member variable ( it initialized to zero at the begining)  as a result get code data from 0x4 address

3. branch with code memory data (i.e., 0xE5000005)

4. prefetch abort

what am i missing to using virtual function. ?

please help me !!!