This is getting weird. Ship inherits from Entity and MerchantShip from Ship, other types are to be added later, but the basic idea, and what is asked by the professor, is that I use polymorphism, so that I can work on a collection of the main class (pointer with allocated memory used as an array in my implementation), thus there is a virtual void update in all three of the later classes. In fact I have used all combinations of virtual and non-virtual functions that could make sense. Code:

```
#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;

class Entity
{
public:
    int x, y;
    virtual void update() = 0;
    void print()
    {
        cout << "x:" << x << ", y:" << y << endl;
    }
};

class Ship: public Entity
{
public:
    virtual void update()
    {
        Move();
    }

    void Move(){x++;};
};

class MerchantShip: public Ship
{
public:
    void update()
    {
        DontMove();
    }

    void DontMove(){};
};

int main(int argc, char* argv[])
{
    int EntityNumber = 2;
    Entity* entities;
    entities = (Entity*)malloc(EntityNumber*sizeof(Entity));
    for (int i = 0; i < EntityNumber; i++)
    {
        entities[i].print();
        entities[i].update();
        entities[i].print();
        cout << endl << "next ship: " << endl;
    }
    system("PAUSE");
    return 0;
}

```

Ok, so it compiles great (stdafx.h is only needed in Visual Studio) but I get a runtime error, which is an access violation at 0xffffffffffffffff when it tries to get into the overridden update functions. In the debug information it consistently looks like the virtual function pointer (\_\_vfptr) is pointing clearly elsewhere than where it should be (0xcdcdcdcdcdcdcdcd), and it's always the same location, even in another code I tried to do the same thing.

Research so far:
cause #1 (does not apply): uses function in a DLL that was freed before being called
cause #2 (again does not apply): programmer forgets to inherit.
I have not come across any other issue in any threads with the same problem, and I've been debugging for a couple of days. If I remove override it will just call the Base class's function.
Any clues?