#include <iostream>
#include <vector>
#include <memory>

using namespace std;

class Entity {
public:

    int index;
    Entity() {};
    virtual ~Entity() {};
    virtual void hit() = 0;
};
class Mesh : public Entity {

public:
    //int index;     // No don't redefine:  here you'd have two different indexes 
    Mesh(int x) {this->index=x;};
    void hit() override {}   // extraa safety: use override instead of virtual to be sure to override
};

int main() {
    vector<unique_ptr<Entity>> objects;
    objects.push_back(unique_ptr<Entity>(new Mesh(35)));
    objects.push_back(unique_ptr<Entity>(new Mesh(10)));

    for ( int i = 0 ; i < objects.size() ; i++ )
        cout << objects[i]->index << endl;

    return 0;
}                