hi all
basically my problem is i have to write a function such that when ever
i call this function in some other function .it should give me tha data
type and value of calling function parameter.and no of parameter is
calling function can be anything.
for example.suppose my function is function2.
then when i call
function1(int i ,char j,float d)
{
function2()
}
ouput should be
i is integer
j is char
d is float
and data type can be anything 6 1921
On 24 Jan 2005 20:47:35 -0800, "komal" <av*************@gmail.com>
wrote: hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
and data type can be anything
I question the wisdom or usefulness of doing this. Sounds like a
homework assignment to me.
Anyway, you can try using the ellipsis and va_arg, but there are
certain restrictions as to the types of arguments you can pass. Most
importantly, the standard says that invoking va_arg on non-POD class
types results in undefined behavior (section 5.2.2 part 7). To use
va_arg, you need to include <cstdarg>.
Also, check out the std::type_info class for non-POD class RTTI.
Include the header <typeinfo> to use this class.
--
Bob Hairgrove No**********@Home.com
komal wrote: hi all basically my problem is i have to write a function such that when
ever i call this function in some other function .it should give me tha
data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
Impossible. function2 doesn't get any information about function1.
At the very least, you should write it as
f1(int i ,char j,float d) { f2( &f1 ); }
In that case, f2 can be a template. With Template Argument Deduction
you can then at least know the types. Still, the variable names are
only for the compiler and not available at runtime.
Regards,
Michiel Salters
komal wrote: hi all basically my problem is i have to write a function such that when
ever i call this function in some other function .it should give me tha
data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
Impossible. function2 doesn't get any information about function1.
At the very least, you should write it as
f1(int i ,char j,float d) { f2( &f1 ); }
In that case, f2 can be a template. With Template Argument Deduction
you can then at least know the types. Still, the variable names are
only for the compiler and not available at runtime.
Regards,
Michiel Salters
Bob Hairgrove wrote: On 24 Jan 2005 20:47:35 -0800, "komal" <av*************@gmail.com> wrote:
hi all basically my problem is i have to write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
and data type can be anything
I question the wisdom or usefulness of doing this. Sounds like a homework assignment to me.
Anyway, you can try using the ellipsis and va_arg, but there are certain restrictions as to the types of arguments you can pass. Most importantly, the standard says that invoking va_arg on non-POD class types results in undefined behavior (section 5.2.2 part 7). To use va_arg, you need to include <cstdarg>.
And it wouldn't help anyway.
When working with va_arg you already need to know the type of the
passed arguments. That's one reason why printf has those fancy %d, %f
&c, %s, ... formatting flags.
--
Karl Heinz Buchegger kb******@gascad.at
komal wrote: hi all basically my problem is i have to write a function such that when
ever i call this function in some other function .it should give me tha
data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
Impossible. function2 doesn't get any information about function1.
At the very least, you should write it as
f1(int i ,char j,float d) { f2( &f1 ); }
In that case, f2 can be a template. With Template Argument Deduction
you can then at least know the types. Still, the variable names are
only for the compiler and not available at runtime.
Regards,
Michiel Salters
komal wrote: hi all basically my problem is i have to write a function such that when
ever i call this function in some other function .it should give me tha
data type and value of calling function parameter.and no of parameter is calling function can be anything. for example.suppose my function is function2. then when i call function1(int i ,char j,float d) { function2() }
ouput should be i is integer j is char d is float
Impossible. function2 doesn't get any information about function1.
At the very least, you should write it as
f1(int i ,char j,float d) { f2( &f1, i,j,d ); }
In that case, f2 can be a template. With Template Argument Deduction
you can then at least know the types. Still, the variable names are
only for the compiler and not available at runtime.
Regards,
Michiel Salters This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lawrence |
last post by:
I've been bad about documentation so far but I'm going to try to be
better. I've mostly worked alone so I'm the only one, so far, who's
suffered from my bad habits. But I'd like other programmers...
|
by: Derek Hart |
last post by:
I wish to execute code from a string. The string will have a function name,
which will return a string:
Dim a as string
a = "MyFunctionName(param1, param2)"
I have seen a ton of people...
|
by: JKop |
last post by:
Take the following simple function:
unsigned long Plus5Percent(unsigned long input)
{
return ( input + input / 20 );
}
Do yous ever consider the possibly more efficent:
|
by: Webdiyer |
last post by:
I want to integrate SecurID two-factor authentication system of the
RSASecurity.inc into our asp.net application,but I get into trouble when
trying to call the API functions of the ACE Agent,I got...
|
by: Neo The One |
last post by:
I think C# is forcing us to write more code by enforcing a rule that can be
summarized as 'A local variable must be assgined *explicitly* before reading
its value.'
If you are interested in what...
|
by: Alan Silver |
last post by:
Hello,
I'm a bit surprised at the amount of boilerplate code required to do
standard data access in .NET and was looking for a way to improve
matters. In Classic ASP, I used to have a common...
|
by: Mr Newbie |
last post by:
I am often in the situation where I want to act on the result of a function,
but a simple boolean is not enough. For example, I may have a function
called
isAuthorised ( User, Action ) as ?????...
|
by: hzmonte |
last post by:
Correct me if I am wrong, declaring formal parameters of functions as
const, if they should not be/is not changed, has 2 benefits;
1. It tells the program that calls this function that the...
|
by: StephQ |
last post by:
This is from a thread that I posted on another forum some days ago.
I didn't get any response, so I'm proposing it in this ng in hope of
better luck :)
The standard explanation is that pointer...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |