search

Home  >  Q&A  >  body text

c++ - 当类中存在一个与某个常成员函数同名的成员函数,那当使用普通对象调用此函数会发生什么?

大家讲道理大家讲道理2805 days ago530

reply all(1)I'll reply

  • 迷茫

    迷茫2017-04-17 14:58:29

    There is no particularly good way. You can call a const member function through a temporary const reference.

    int main() {
        A a;
        const A& b = a;
        b.getI();
    }

    reply
    0
  • Cancelreply