不工作
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];'
但是,替换*this[0]为at(0)使其工作。我发现它*this[0]返回一个类型的对象A而不是int像at(0)这样的对象非常奇怪。在这个例子中他们不应该以同样的方式工作吗?