checking if the value is an number or a character, is there such function?

J

jalkadir

I am looking for a C++ method that will tell me if the value returned
is a int, double, floeat, etc. Is there such a method in C++?

Thanks folks
 
M

Mike Wahler

jalkadir said:
I am looking for a C++ method that will tell me if the value returned
is a int, double, floeat, etc. Is there such a method in C++?

Certainly. Whatever return type you define.

int i()
{
return 0; /* returns a type 'int' object */
}

double d()
{
return 0; /* returns a type 'double' object */
}


-Mike
 
S

Stranger

well I think he wants to define how the returned type is , as Mike said
the type of returned data is clear in C++ , cause it is the exact type
that you have declared when you were declaring the function. But if you
are using VC++ or something else that contain datatypes that can accept
different types like we have in delphi , I think i have read something
like this in C++ but not sure about it . but give sizeof() a try , it
might help you .

Shahab.
 
B

ben

jalkadir said:
I am looking for a C++ method that will tell me if the value returned
is a int, double, floeat, etc. Is there such a method in C++?

Thanks folks

The return type of any function can be and is determined at compile
time. Even by looking at the function declaration can tell you what type
does the function return.

Perhaps you are talking about something else, things like type reflection?

If the function you are expecting does exist, what would you think it
would look like? Is the following the example of what you are looking for:

int add(int a, int b);

string rettype = get_return_type("add"); // returns "int"

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top