Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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:

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


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

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

and the detector will return:

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


Somthing like that. Any suggestion is highly appreciated. Thanks. Nick
Posted
Updated 3-Oct-12 4:47am
v3
Comments
Richard MacCutchan 3-Oct-12 10:59am    
You can do this in .NET with reflection but not in pure C++ as far as I know.
Legor 4-Oct-12 3:50am    
Maybe it can be done with generic programming. But in general C++ doesn't provide reflection.

1 solution

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...)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900