Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我重载了双括号函数并在同一个类中使用它作为 c++ 中的矩阵?我相信我正确地重载了它,但我不知道如何从内部调用它。
我假设您的双括号函数是operator(),那么您可以通过两种不同的方式从其他成员函数内部调用它:
operator()
unsigned operator()(unsigned i) const { if(i == 0) return 1; return operator()(i-1); }
或者
unsigned operator()(unsigned i) const { if(i == 0) return 1; return (*this)(i-1); }