Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

C++: Surcharge d’une fonction générique


{filelink=15769}

#include <iostream>
using std::cout;
using std::endl;
 
template <class T> void test(T a)
{
  cout << "Fonction #1 a= "<<a<<endl;
}
 
template <class T, class Z> void test(T a, Z b)
{
  cout << "Fonction #2 a= "<<a;
  cout << " b= "<<b<<endl;
}
 
int main()
{
  test(5);
  test(10, 20);
  test(1.5);
  test(1.10, 1.20);
  return 0;
}

No comments yet.

Leave a Comment