User Tools

Site Tools


c_-_c_templates:class_template_-_typeid

C - C++ Templates - Class Template - Typeid

#include <iostream>
#include <typeinfo>
 
// Declaration of template.
template <typename T>
void print_typeof (T const&);
 
 
// Implementation/definition of template.
template <typename T>
void print_typeof (T const& x)
{
  std::cout << typeid(x).name() << std::endl;
}
 
 
int main()
{
  double ice = 3.0;
  print_typeof(ice);  // call function template for type double
}
c_-_c_templates/class_template_-_typeid.txt · Last modified: 2020/07/15 10:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki