I have overloaded the [] operator in my class. here is the implementation
Node* List::operator [](int index) const{
Node* p = head_;
for (int i = 0; i < index; i++){
p = p->link();
}
return p;
}
I have another function in the class in which I want to access the Node* returned. one of the lines is
if ((n = index_of_name(artistName)) >= 0){
Node* p = // code needed here
}
I want to be able to access the node at n by using the overloaded[]. How can I do that?