<Class T>

We have just learned about templates in my class.

Is there any way to know what type of data the variable is? Something like:

1
2
3
template <class T> void whatType(T data) {
  cout << "I am a " << //...
}


Know what I mean? If the function was passed an int, it would say "I am an int", or something along those lines. The computer knows what type it is, how can I?
For example you can use typeid

cout << typeid( T ).name() << endl;
Topic archived. No new replies allowed.