首页 > 代码库 > 柔性数组,数据类型大小
柔性数组,数据类型大小
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 }
——written by LyonLys
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。