H
Hunter Hou
Hello,
I'm trying one example of <<the C++ programming language>> Page 865
int f( int );
template< class T > T g( T t ) { return f( t ); }
char c = g( 'a' ); ************
char f( char );
Stroustrup said **** line is wrong because alternative resolution of f( t )
are possible.
But I used g++ in mingw to compile above code, there's nothing wrong. My
code is like this:
//template_study.cpp
int f( int );
template< class T > T g( T t ) { return f( t ); }
char c = g( 'a' );
char f( char );
int main() { return 0; }
Who would like to shed some light on me?
And who can explain further about template instantiation and namespace? I
don't quite understand what Stroustrup says.
Thanks,
Hunter
I'm trying one example of <<the C++ programming language>> Page 865
int f( int );
template< class T > T g( T t ) { return f( t ); }
char c = g( 'a' ); ************
char f( char );
Stroustrup said **** line is wrong because alternative resolution of f( t )
are possible.
But I used g++ in mingw to compile above code, there's nothing wrong. My
code is like this:
//template_study.cpp
int f( int );
template< class T > T g( T t ) { return f( t ); }
char c = g( 'a' );
char f( char );
int main() { return 0; }
Who would like to shed some light on me?
And who can explain further about template instantiation and namespace? I
don't quite understand what Stroustrup says.
Thanks,
Hunter