template<class T>
void fun1(T a)
{
T x,y;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
template<class T>
void fun2(T *a)
{
//T x,y;
//T x=0,y=0;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
template<class T>
void fun3(const T *a)
{
T x,y;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
void main()
{
int a = 10;
const int b = 20;
int *ip = &a;
const int *cp = &b;
//fun1(a); //int int
//fun1(b); //int int
//fun1(&a); //int * int *
//fun1(&b); //int const * int const *
//fun1(ip); //int * int *
//fun1(cp); //int const * int const *
//fun1(&ip); //int ** int **
//fun1(&cp); //int const ** int const **
//fun2(a); //出错
//fun2(b); //出错
//fun2(&a); //int int *
//fun2(&b); //int int const *
//fun2(ip); //int int *
//fun2(cp); //int int const *
//fun2(&ip); //int * int **
//fun2(&cp); //int const * int const **
//fun3(a); //出错
//fun3(b); //出错
//fun3(&a); //int int const *
//fun3(&b); //int int const *
//fun3(ip); //int int const *
//fun3(cp); //int int const *
//fun3(&ip); //int * int *const *
//fun3(&cp); //int const * int const *const*
}
void fun1(T a)
{
T x,y;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
template<class T>
void fun2(T *a)
{
//T x,y;
//T x=0,y=0;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
template<class T>
void fun3(const T *a)
{
T x,y;
cout<<typeid(T).name()<<endl;
cout<<typeid(a).name()<<endl;
}
void main()
{
int a = 10;
const int b = 20;
int *ip = &a;
const int *cp = &b;
//fun1(a); //int int
//fun1(b); //int int
//fun1(&a); //int * int *
//fun1(&b); //int const * int const *
//fun1(ip); //int * int *
//fun1(cp); //int const * int const *
//fun1(&ip); //int ** int **
//fun1(&cp); //int const ** int const **
//fun2(a); //出错
//fun2(b); //出错
//fun2(&a); //int int *
//fun2(&b); //int int const *
//fun2(ip); //int int *
//fun2(cp); //int int const *
//fun2(&ip); //int * int **
//fun2(&cp); //int const * int const **
//fun3(a); //出错
//fun3(b); //出错
//fun3(&a); //int int const *
//fun3(&b); //int int const *
//fun3(ip); //int int const *
//fun3(cp); //int int const *
//fun3(&ip); //int * int *const *
//fun3(&cp); //int const * int const *const*
}