1
我已经重载了我的类中的[]运算符。这里是执行在C++中访问重载运算符
Node* List::operator [](int index) const{
Node* p = head_;
for (int i = 0; i < index; i++){
p = p->link();
}
return p;
}
我有我想访问节点返回类中的另一个函数。其中一行是
if ((n = index_of_name(artistName)) >= 0){
Node* p = // code needed here
}
我想通过使用重载的[]来访问n节点。我怎样才能做到这一点?
嗅闻嗅闻....闻起来有点家庭作业。 从干净的代码到这一点的所有“代码需要在这里”部分...... – Dan 2009-06-02 03:56:29