stat_mem.cpp
来自「本代码是《C/C++程序员实用大全》的配套代码。网络转载」· C++ 代码 · 共 41 行
CPP
41 行
#include <iostream.h>
class shared
{
static int a;
int b;
public:
void set(int i, int j)
{
a=i;
b=j;
}
void show();
};
int shared::a; // Define the a global variable
void shared::show()
{
cout << "This is static a: " << a << endl;
cout << "This is non-static b: " << b << endl;
}
void main(void)
{
shared x, y;
x.set(1,1);
x.show();
y.set(2,2);
y.show();
x.show();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?