自考新教材-p144_4

阅读 155

2022-06-08

源程序:

#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;
}

运行结果:

自考新教材-p144_4_ios

 


精彩评论(0)

0 0 举报