• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
LyonLys
愿意在角落唱沙哑的歌 再大声也都是给你 请用心听 不要说话 Contact me via E-mail: lyon.lys@gmail.com
博客园    首页    新随笔    联系   管理    订阅  订阅

柔性数组,数据类型大小

http://www.nowamagic.net/academy/detail/1204478

http://www.nowamagic.net/academy/detail/1204480

 

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 template<class T1, class T2>
 5 class MyPair { T1 first; T2 second; } ;
 6 class MyClass1 { char a, b; long double c; } ;
 7 class MyClass2 { long double a; char b; } ;
 8 class MyClass3 { char a; MyClass1 b; } ;
 9 class MyClass4 { char a; MyClass3 b; } ;
10 class MyClass5 { char a; int b; } ;
11 class MyClass6 { char a; MyClass5 b; } ;
12 class MyClass7 { char a, b; } ;
13 class MyClass8 { char a, *b; } ;
14 
15 int main() {
16     cout << "vector " << sizeof(vector<int>) << endl;
17     cout << "map " << sizeof(map<int, int>) << endl;
18     cout << "multimap " << sizeof(multimap<int, int>) << endl;
19     cout << "set " << sizeof(set<int>) << endl;
20     cout << "multiset " << sizeof(multiset<int>) << endl;
21     cout << "priority_queue " << sizeof(priority_queue<int>) << endl;
22     cout << "deque " << sizeof(deque<int>) << endl;
23     cout << "queue " << sizeof(queue<int>) << endl;
24     cout << "stack " << sizeof(stack<int>) << endl;
25     cout << "list " << sizeof(list<int>) << endl;
26     cout << "string " << sizeof(string) << endl;
27     cout << "complex<double> " << sizeof(complex<double>) << endl;
28     cout << "bool[1 << 6] " << sizeof(bool[1 << 6]) << endl;
29     cout << "bool[1 << 6 | 1] " << sizeof(bool[1 << 6 | 1]) << endl;
30     cout << "bitset<1 << 6> " << sizeof(bitset<1 << 6>) << endl;
31     cout << "bitset<1 << 8> " << sizeof(bitset<1 << 8>) << endl;
32     cout << "int " << sizeof(int) << endl;
33     cout << "double " << sizeof(double) << endl;
34     cout << "long double " << sizeof(long double) << endl;
35     cout << "pair<int, int> " << sizeof(pair<int, int>) << endl;
36     cout << "pair<double, int> " << sizeof(pair<double, int>) << endl;
37     cout << "pair<double, long long> " << sizeof(pair<double, long long>) << endl;
38     cout << "pair<double, long double> " << sizeof(pair<double, long double>) << endl;
39     cout << "MyPair<long double, int> " << sizeof(MyPair<long double, int>) << endl;
40     cout << "MyClass1 " << sizeof(MyClass1) << endl;
41     cout << "MyClass2 " << sizeof(MyClass2) << endl;
42     cout << "MyClass3 " << sizeof(MyClass3) << endl;
43     cout << "MyClass4 " << sizeof(MyClass4) << endl;
44     cout << "MyClass5 " << sizeof(MyClass5) << endl;
45     cout << "MyClass6 " << sizeof(MyClass6) << endl;
46     cout << "MyClass7 " << sizeof(MyClass7) << endl;
47     cout << "MyClass8 " << sizeof(MyClass8) << endl;
48     return 0;
49 }
View Code

 

——written by LyonLys

posted @ 2014-07-22 05:32  LyonLys  阅读(256)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3