对类中的对象使用方法

Using methods for the objects in class

本文关键字:对象 使用方法      更新时间:2023-10-16

如何调用我在类中为我的私有变量声明的方法?此代码导致失败:未声明的方法 At。我想在函数 Top(( 中使用我之前声明的方法 At((。请帮忙:) 例如:

class A{
public:
void At(size_t i){
Check_i(i);
return one[i];     
}
void Top(){
return one.At(i);
}
private:
vector<int> one;
}

use pointer 'this', void Top(size_t i( {return this->At(i(;}