In C++, "data" and "operations (functions) that process data" are stored separately.
Class object members—the size of object space occupied by ordinary member variables
Class object members—static member variables do not occupy the object space
Class object members—ordinary member functions do not occupy the object space
Class object members—static member functions do not occupy object space
#include <iostream>
#include <string.h>
using namespace std;
class Person
{
public:
int a;//普通的成员变量
static int b;//静态成员变量不存在类实例化的对象中
void show()//普通成员函数不存在类实例化的对象中
{
}
static void show1()//静态成员函数不存在类实例化的对象中
{
}
};
int Person::b = 1;
int main()
{
Person p;
p.show();
cout << "sizeof(person) = " << sizeof(Person)<< endl;
return 0;
}