编译和运行代码时
#include <iostream>
struct A { A(int){} };
void foo( int ) { std::cout << "foo(int)" << std::endl; }
template< typename T >
struct S {
void bar() { foo( 5 ); }
void foobar() { T t = 5; foo(t); }
};
inline void foo( A ) { std::cout << "foo(A)" << std::endl; }
inline void foo( double ) { std::cout << "foo(double)" << std::endl; }
int main(int argc, char* argv[])
{
S<double> s0;
s0.bar();
s0.foobar();
std::cout << '\n'; …Run Code Online (Sandbox Code Playgroud)