[ create a new paste ] login | about

Link: http://codepad.org/sHHke4V9    [ raw code | output | fork ]

C++, pasted on Nov 3:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
template<typename T> void func( T );
template<>
void func<int>( int i ){ cout << "template" << endl; }
//void func( int i ){ cout << "normal" << endl; }

template<typename T> void func_( T );
template<>
void func_<int>( int i ){ cout << "template" << endl; }
void func_( int i ){ cout << "normal" << endl; }

int main( void ){
    func(1);          // これは当然

    func_<int>(1);    // これも当然
    func_(1);         // なぜオーバーロードの方が呼ばれるのか

    return 0;
}


Output:
1
2
3
template
template
normal


Create a new paste based on this one


Comments: