Ambiguity between 'vector::at' and 'vector::at const'

0
class Base: protected vector<int> { ... };
class Derived: public Base { ...
   int somefunc() { return at(0); }; // <--- error
};

Przy próbie komplilacji (BCB6) otrzymuje komunikat:

[C++ Error] tapmain.cpp(11): E2015 Ambiguity between '_STL::vector<int,_STL::allocator<int> >::at(unsigned int)' and '_STL::vector<int,_STL::allocator<int> >::at(unsigned int) const'

Problem znika przy publicznym dziedziczeniu vector'a przez klase Base !?!?
Skąd się bierze ten error ?
Jak sobie z nim poradzić ?

Ostatecznie moge zrobić coś takiego:

class Base: protected vector<int> { ... 
   int At(unsigned Index) { return at(Index); }; // <--- dolozona funkcja 
};

class Derived: public Base { ...
   int somefunc() { return At(0); }; // <--- 'At' zamiast 'at'
};

ale wtedy musze tak zrobić z każdą funkcją vector'a jaką chce użyć, nie tyko 'at' :/

0

Spróbuj tak:

class Base: protected vector<int>
{
   ...
};

class Derived: public Base
{
public:
   int somefunc() { return this->at(0); }
};

1 użytkowników online, w tym zalogowanych: 0, gości: 1