mercredi 28 juin 2017

overloading indirection operator fails

I have an inner class which is a custom iterator. I override the indirection operator like this:

    T& operator*() {
        return matrix->getCell(cuurent_coord);
    }

Yet, when using the iterator and applying the operator:

for (auto iter = m1.begin(); iter != m1.end(); iter++) {
    int i = *iter;
}

I get the following error: no suitable conversion function from "Foo::FooIterator to "int" exists.

It seems that the compiler ignored the overriding. Why?

Aucun commentaire:

Enregistrer un commentaire