是否可以检测另一个函数的参数类型,值以及名称和返回值的函数? [英] A function that detects the parameter type, value, and the name and return value of another function?

查看:46
本文介绍了是否可以检测另一个函数的参数类型,值以及名称和返回值的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以编写一个函数来检测参数类型,值和函数名称以及另一个函数的返回值.

例如.我有一个功能:

I am wondering if how I can write a function to detect the parameter type, value and function name and return value of another function.

For example. I have a function:

double average(string datapath, double *data, int numofinput)
{
   // some code here
}



我想要另一个函数,例如detector(),可以将其插入要检测的函数中,例如



I want to have another function, such as detector(), which can be inserted into the function to be detected, like

double average(string datapath, double *data, int numofinput)
{   
   // some code here
   detector();
}


探测器将返回:


and the detector will return:

name: average
returned value: 2.43
pathname: string='C:/Users/Nick/Data/'
data: pointer=0x0065
numofinput: int=17



这样的事.任何建议都将受到高度赞赏.谢谢. Nick



Somthing like that. Any suggestion is highly appreciated. Thanks. Nick

推荐答案

尝试创建一个(类)字符串变量str,
每次调用一个函数时,它都会更新str中的数据(覆盖它或只是添加它),最后,确定str的值.

(我认为您只是用它来执行调试...)
try creating a (class) string variable str,
and everytime a function is called, it updates the data in str (either overwrite it or just add), at the end, cout the value of str.

(i think you are just using it to perform debuging...)


这篇关于是否可以检测另一个函数的参数类型,值以及名称和返回值的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆