自考新教材-p144_4

源程序:

#include <iostream>
using namespace std;

class Test
{
private:
static int num;
public:
Test(int);
void show();
};
int Test::num = 5;
Test::Test(int n)
{
num = n;
}
void Test::show()
{
cout << num << endl;
}
int main()
{
Test t(10);
t.show();
system("pause");
return 1;
}

运行结果:

 

posted @ 2020-02-06 19:48  bobo哥  阅读(142)  评论(0编辑  收藏  举报