Doesn't work
class A : public std::vector<int>
{
explicit A()
{
push_back(5);
std::cout << *this[0];
}
}
error: no match for 'operator*' (operand type is 'A')
std::cout << *this[0];'
Replacing *this[0]
with at(0)
makes it work, though. I find it very wierd that *this[0]
returns an object of type A
and not int
, as at(0)
does. Shouldn't they work the same way in this example?