是否还有使用成员函数作为默认参数? [英] Is there anyway to use a member function as a default parameter?
本文介绍了是否还有使用成员函数作为默认参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它尝试这样的东西,这不工作。是否有办法获得类似的效果?
It tried something like this, which doesn't work. Is there a way to get a similar effect?
class A
{
public:
int foo();
void bar(int b = foo());
};
推荐答案
重载函数并调用它的成员函数。
Yes. Overload the function and call the member-function in it.
void bar(){bar(foo()); }
这篇关于是否还有使用成员函数作为默认参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文