【c++11关键字】 sizeof
2020-10-29 本文已影响0人
小鱼号的代码日记
/*
* c++11关键字
* sizeof
* 小鱼号的代码日志
*/
#include <QCoreApplication>
#include <iostream>
using namespace std;
struct Empty{};
struct Base{int a;};
struct Derived:Base
{
int b;
};
struct Bit
{
unsigned bit:1;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Empty e;
Derived d;
Base& b = d;
Bit bit;
cout << sizeof(e) << endl;
cout << sizeof(Empty) << endl;
cout << sizeof(&e) << endl;
cout << sizeof(Derived) << endl;
cout << sizeof(d) << endl;
cout << sizeof(void) << endl;//BAD
return a.exec();
}