954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can i find out a parameter's type?

How can i find out a parameter's type?
e.g.

char no1='a';

which function can i use to find out no1 is char type?

fun(no1)

reture the no1's type

see_moonlight
Newbie Poster
7 posts since Oct 2004
Reputation Points: 10
Solved Threads: 0
 
#include <iostream>
#include <string>
#include <typeinfo>

using namespace std;

template <typename T>
string typeof ( T arg )
{
  return typeid ( arg ).name();
}

int main()
{
  char ch = 'a';

  cout<< typeof ( ch ) <<endl;
}
Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You