它尝试了类似的方法,但行不通。有没有办法获得类似的效果?
class A { public: int foo(); void bar(int b = foo()); };
是的。重载该函数并调用其中的成员函数。
void bar() { bar(foo()); }