我在我的类中重载了[]运算符。下面是实现
Node* List::operator [](int index) const{
Node* p = head_;
for (int i = 0; i < index; i++){
p = p->link();
}
return p;
}我在类中有另一个函数,我想在其中访问返回的Node*。其中一行是
if ((n = index_of_name(artistName)) >= 0){
Node* p = // code needed here
}我希望能够使用overloaded[]访问n处的节点。我该怎么做呢?
发布于 2009-06-02 02:25:48
(*this)[n]https://stackoverflow.com/questions/937670
复制相似问题