This commit is contained in:
xliu79
2020-07-19 10:38:38 +08:00
parent 9f6088a31e
commit 2bdeea85d1
129 changed files with 5264 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/**
* @file static.cpp
* @brief 静态数据成员
* 静态数据成员被编译器放在程序的一个global data members中它是类的一个数据成员但不影响类的大小。不管这个类产生了多少个实例还是派生了多少新的类静态数据成员只有一个实例。静态数据成员一旦被声明就已经存在。
* @author 光城
* @version v1
* @date 2019-07-21
*/
#include<iostream>
using namespace std;
class A
{
public:
char b;
virtual void fun() {};
static int c;
static int d;
static int f;
};
int main()
{
/**
* @brief 16 字节对齐、静态变量不影响类的大小、vptr指针=8
*/
cout<<sizeof(A)<<endl;
return 0;
}