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 1970
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(in t 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**********@Ho me.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(in t 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 to have an
easier time understanding what I do. Therefore this weekend I'm going
to spend 3 days just writing comments. Before I do it, I thought I'd
ask other programmers what information they find useful.
Below is a typical class I've...
|
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 discuss how reflection does this, but I cannot
find the syntax to do this. I have tried several code example off of
gotdotnet and other articles. Can somebody please show me the code to do
this?
|
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 an error message
saying "Cannot marshal parameter #2: Invalid managed/unmanaged type
combination (this value type must be paired with Struct)" when calling
"AceGetPinParams(iHandle,ref sd_pin)" function,here's my test code:
private static...
|
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 I mean, please look at this feedback my me:
http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=3074c204-04e4-4383-9dd2-d266472a84ac
If you think I am right, please vote for this feedback.
| |
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 function that was
included in all pages that took an SQL query and returned a disconnected
recordset. This meant that data access could be achieved in a single
line. I would like to do something similar in ASP.NET.
I know I could just duplicate...
|
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 ?????
OK, this function may return a boolean, and if this is true, then no message
back is really required, but if it fails then some supporting message needs
to be returned to the calling code. As I see it there are a few options.
|
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 parameter
will not be changed - so don't worry.
2. It tells the implementor and the maintainer of this function that
the parameter should not be changed inside the function. And it is for
this reason that some people advocate that it is a good idea to...
|
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 to functions are hard to
inline for the compiler, and so you won't be able to avoid function
call overhead.
This is an important aspect when you are calling a function very
frequently for evaluation reason: think of the problem of performing...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |