windtrace

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

亲测,基于win7 32位,vs2012编译

结果:

代码:

 1 #include "stdafx.h"
 2 #include <iostream>
 3 #include <iomanip>
 4 #include <limits>
 5 using namespace std;  
 6 
 7 
 8 template<typename T>
 9 void Output()
10 {
11     cout<<left <<setw (18)<<typeid(T).name()<<setw (8)<<sizeof(T)<<numeric_limits<T>::min()<<""<<numeric_limits<T>::max()<<endl;
12 }
13 
14 int _tmain(int argc, _TCHAR* argv[])
15 {
16     cout<<left <<setw (18)<<"数据类型"<<setw (8)<<"字节数"<<"取值范围"<<endl;
17     Output<bool> ();
18     cout<<left <<setw (18)<<typeid(char).name()<<setw (8)<<sizeof(char)<<(int)numeric_limits<char>::min()<<""<<(int)numeric_limits<char>::max()<<endl;
19     Output<wchar_t> ();
20     cout<<endl;
21 
22     Output<short> ();
23     Output<unsigned short> ();
24     Output<int> ();
25     Output<unsigned int> ();
26     Output<long int> ();
27     Output<unsigned long int> ();
28     Output<long long int> ();
29     Output<unsigned long long int> ();
30     cout<<endl;
31     
32     Output<float> ();
33     Output<double> ();
34     Output<long double> ();
35     cout<<endl;
36 
37     system("pause");
38     return 0;  
39 }

 

posted on 2017-03-29 09:02  windtrace  阅读(289)  评论(0)    收藏  举报