avatar
pointer to override function?# Programming - 葵花宝典
J*n
1
I need to let function A be an argument for function B,
but function A has two forms (override), how can I
include the two types as a general form of A in argument of B?
for example
float A(int);
float A(int, double);
I want
float B((*A)(?),other arguments)
how do I substitute content denoted by "?"
avatar
p*o
2
Then how to call them in B?

【在 J*****n 的大作中提到】
: I need to let function A be an argument for function B,
: but function A has two forms (override), how can I
: include the two types as a general form of A in argument of B?
: for example
: float A(int);
: float A(int, double);
: I want
: float B((*A)(?),other arguments)
: how do I substitute content denoted by "?"

avatar
J*n
3
you are right, this design is problematic.

【在 p***o 的大作中提到】
: Then how to call them in B?
avatar
Q*g
4
可以用function object吧
class A{
float operator()(int){...}
float operator()(int, double){...}
}
然后传一个A的实例的指针给B.

【在 J*****n 的大作中提到】
: I need to let function A be an argument for function B,
: but function A has two forms (override), how can I
: include the two types as a general form of A in argument of B?
: for example
: float A(int);
: float A(int, double);
: I want
: float B((*A)(?),other arguments)
: how do I substitute content denoted by "?"

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。