65,180
社区成员




#include <iostream>
#include <string>
template<typename T>
void Foo(const T& e)
{
std::cout << "The input var type size:" << sizeof(T) <<std::endl
<< "The var value:" << e << std::endl;
}
void Foo(const int& e)
{
std::cout << "The input var type size:" << sizeof(int) <<std::endl
<< "The var value:" << e << std::endl;
}
template<>
void Foo<int>(const int& e)
{
std::cout << "The input var type size:" << sizeof(int) <<std::endl
<< "The var value:" << e << std::endl;
}
int main()
{
int a(12);
std::string b("wang");
Foo(a);
Foo(b);
}
#include <iostream>
#include <string>
using std::string;
template<typename T>
void Foo(const T& e)
{
std::cout << "The input var type size:" << sizeof(T) <<std::endl
<< "The var value:" << e << std::endl;
}
int main()
{
int a(12);
Foo(a);
}
template<>
void Foo<int>(const int& e)
{
std::cout << "The input var type size:" << sizeof(int) <<std::endl
<< "The var value:" << e << std::endl;
}
void Foo(const int& e);
template<typename T> void Foo(const T& e);
template<>
void Foo<int>(const int& e);
void Foo(const int& e);