Q:

Function changes const object

I have function which accepts const reference as argument.  It should not change argument, but it does (variable "_isVertex").  How can this be fixed?  Here is the code:
#include <vector>
#include <iostream>

using namespace std;

class Element
{
public:
    bool isVertex() const
    { return _isVertex; };

private:
    bool _isVertex = true;
};

class ElementContainer : public vector <Element>
{
public:
    void push(const Element &t)
    {
        // here everything is fine
        cerr << t.isVertex() << ' ';
        push_back(t);
        // and here _isVertex is false, should be true! 
        cerr << t.isVertex() << '\n';
    }
};

int main()
{
    ElementContainer vertex;

    vertex.push({});
    vertex.push(vertex[0]);
}

A:

Consider carefully vertex.push(vertex[0]);.  t in the function push is a constant reference to vertex[0]. 
But after the push_back, the contents of the vector have moved (due to a memory reallocation), and therefore vector[0] has moved elsewhere.  t is now a dangling reference. 
That's undefined behaviour.  Boom.