欢迎来到天天文库
浏览记录
ID:44232152
大小:315.58 KB
页数:10页
时间:2019-10-19
《第5章上机实验报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、第5章上机实验报告一、实验目的(1)观察程序运行中变量的作用域74。(2)学习类的静态成员的使用。(3)学习多文件结构的C++程序屮的使用。二、实验任务(1)运行下面的程序,观察变量x,y的值。【代码Iab5-1]#include〃iostreanTusingnamespacestd;voidfun();intx=l,y二2;intmeiin(){cout<<,,Begin..."〈〈endl;cout<<,zx=//<2、ndl;intx二10,y二20;cout<<,zx=/z<3、td;voidfm();intx=1,j4、=2;intnain(){coutOgin...Wl;coutKF喲伽1;cou^CEualuatexandj5、innain()..."«enill;intx呷州;cout«"x="«x«en(ll;cooKCji-'KjiKenil;cout«"$tepintofui)(),.."«enill;侧);cout«"8ackiniain()...ll«endl;coot«¥«伽dl;诞《丁丿〈勺〈〈皿;return8;}uoidfund{intj6、=288;[coot(作《«酣1;//client.httifnd7、efCLIENT_H_INCLUDED^defineCLTENT_H_TNCLUDEDusingnamcspaccstd;classClient{public:Client();Client(Clicnt&p);^Client();staticvoidChangeServerName(stringName);voidshow();private:staticstringserName;staticintclientNum;};Sendif//CL1ENT_H_1NCLUDED//client,epp#include〃iostreamz/#includc8、z,client.h〃usingnamespacestd;intClient::clientNum二0;stringClient::scrNamc=,,scr,/;Client::Client()dientNum++;cout<<,z第〃《clicntNum〈〈“个客户创建,,<9、e=p.serName;cout<#include,zclient.h〃usingnamespacestd;i10、ntmain(){Clientcl;cl.show();cl.ChangcScrvcrMamc(〃cr〃);cl.show();cl.ChangeServerName(z,erz/);Clientc2(cl);c2.show();c2.ChangeServerName(/zqrz,);c2.show();cl.show();return0;}/5-12#includeusingnamespacestd;voidfun(){staticinti=O;i++;cout«l,i="«i«endl;}intmain()for(inti=0;11、i<10;i++)return0;}*/llincludeusingnan
2、ndl;intx二10,y二20;cout<<,zx=/z<3、td;voidfm();intx=1,j4、=2;intnain(){coutOgin...Wl;coutKF喲伽1;cou^CEualuatexandj5、innain()..."«enill;intx呷州;cout«"x="«x«en(ll;cooKCji-'KjiKenil;cout«"$tepintofui)(),.."«enill;侧);cout«"8ackiniain()...ll«endl;coot«¥«伽dl;诞《丁丿〈勺〈〈皿;return8;}uoidfund{intj6、=288;[coot(作《«酣1;//client.httifnd7、efCLIENT_H_INCLUDED^defineCLTENT_H_TNCLUDEDusingnamcspaccstd;classClient{public:Client();Client(Clicnt&p);^Client();staticvoidChangeServerName(stringName);voidshow();private:staticstringserName;staticintclientNum;};Sendif//CL1ENT_H_1NCLUDED//client,epp#include〃iostreamz/#includc8、z,client.h〃usingnamespacestd;intClient::clientNum二0;stringClient::scrNamc=,,scr,/;Client::Client()dientNum++;cout<<,z第〃《clicntNum〈〈“个客户创建,,<9、e=p.serName;cout<#include,zclient.h〃usingnamespacestd;i10、ntmain(){Clientcl;cl.show();cl.ChangcScrvcrMamc(〃cr〃);cl.show();cl.ChangeServerName(z,erz/);Clientc2(cl);c2.show();c2.ChangeServerName(/zqrz,);c2.show();cl.show();return0;}/5-12#includeusingnamespacestd;voidfun(){staticinti=O;i++;cout«l,i="«i«endl;}intmain()for(inti=0;11、i<10;i++)return0;}*/llincludeusingnan
3、td;voidfm();intx=1,j
4、=2;intnain(){coutOgin...Wl;coutKF喲伽1;cou^CEualuatexandj
5、innain()..."«enill;intx呷州;cout«"x="«x«en(ll;cooKCji-'KjiKenil;cout«"$tepintofui)(),.."«enill;侧);cout«"8ackiniain()...ll«endl;coot«¥«伽dl;诞《丁丿〈勺〈〈皿;return8;}uoidfund{intj
6、=288;[coot(作《«酣1;//client.httifnd
7、efCLIENT_H_INCLUDED^defineCLTENT_H_TNCLUDEDusingnamcspaccstd;classClient{public:Client();Client(Clicnt&p);^Client();staticvoidChangeServerName(stringName);voidshow();private:staticstringserName;staticintclientNum;};Sendif//CL1ENT_H_1NCLUDED//client,epp#include〃iostreamz/#includc
8、z,client.h〃usingnamespacestd;intClient::clientNum二0;stringClient::scrNamc=,,scr,/;Client::Client()dientNum++;cout<<,z第〃《clicntNum〈〈“个客户创建,,<9、e=p.serName;cout<#include,zclient.h〃usingnamespacestd;i10、ntmain(){Clientcl;cl.show();cl.ChangcScrvcrMamc(〃cr〃);cl.show();cl.ChangeServerName(z,erz/);Clientc2(cl);c2.show();c2.ChangeServerName(/zqrz,);c2.show();cl.show();return0;}/5-12#includeusingnamespacestd;voidfun(){staticinti=O;i++;cout«l,i="«i«endl;}intmain()for(inti=0;11、i<10;i++)return0;}*/llincludeusingnan
9、e=p.serName;cout<#include,zclient.h〃usingnamespacestd;i
10、ntmain(){Clientcl;cl.show();cl.ChangcScrvcrMamc(〃cr〃);cl.show();cl.ChangeServerName(z,erz/);Clientc2(cl);c2.show();c2.ChangeServerName(/zqrz,);c2.show();cl.show();return0;}/5-12#includeusingnamespacestd;voidfun(){staticinti=O;i++;cout«l,i="«i«endl;}intmain()for(inti=0;
11、i<10;i++)return0;}*/llincludeusingnan
此文档下载收益归作者所有