Click here to Skip to main content
13,000,323 members (69,328 online)
Rate this:
Please Sign up or sign in to 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:

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

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

and the detector will return:

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 3-Oct-12 4:20am
Updated 3-Oct-12 4:47am
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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...)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100