我在班上重载了[]运算符.这是实施
Node* List::operator [](int index) const{
Node* p = head_;
for (int i = 0; i < index; i++){
p = p->link();
}
return p;
}
Run Code Online (Sandbox Code Playgroud)
我在类中有另一个函数,我想要访问返回的Node*.其中一条线是
if ((n = index_of_name(artistName)) >= 0){
Node* p = // code needed here
}
Run Code Online (Sandbox Code Playgroud)
我希望能够通过使用重载[]来访问n处的节点.我怎样才能做到这一点?