template

なるほどなるほど

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>

using namespace std;

template <class T>
void foo(int i){
  cout << "int:" << i << endl;
}

void foo(double d){
  cout << "double:" << d << endl;
}

void foo(string s){
  cout << "string:" << s << endl;
}

int main(int argc, char* argv[]){
  foo<int>(3);
  foo(5555);
  foo(3.14);
  foo("hello work");
}
int:3
double:5555
double:3.14
string:hello work