Skip to content

Instantly share code, notes, and snippets.

@qgp9
Last active April 13, 2017 05:25
Show Gist options
  • Save qgp9/99471ba5d2c39569aa5e46fc5b976d2b to your computer and use it in GitHub Desktop.
Save qgp9/99471ba5d2c39569aa5e46fc5b976d2b to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
// A
template<typename T> void foo(T) {cout<<"A";}
// B
template<typename T> void foo(T*) {cout<<"B";}
// C
template<> void foo<int*>(int*) {cout<<"C";}
// D
template<> void foo<int>(int*) {cout<<"D";}
// E
void foo(int*) {cout<<"E";}
int main(){
int * v;
foo(v); // A~E 중 어느 것이 호출될까?
cout<<endl;
return 0;
}
template<typename T> // A.
void foo(T) {}
template<typename T> // B
void foo(T*) {}
template<> // C
void foo<int*>(int*) {}
int main(){
int * v;
foo(v); // A~C 중 어느 것이 호출될까?
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment