欢迎来到天天文库
浏览记录
ID:55556920
大小:380.50 KB
页数:9页
时间:2020-05-17
《《面向对象程序设计》模拟试卷.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、程序分析题(每小题5分,共10分,请将程序运行结果填入到对应的文本框内。重要提示:1、务必在第Ⅰ卷时间内完成程序分析题,之后无法再修改;2、程序分析题完成后,不要急于提交试卷,否则后果自负。)运行一下就有执行结果,自己动手吧啊,嘿嘿!!!!!!!!!!!!!!1.#include#includeusingnamespacestd;classPerson{public:Person(conststring&stuName):szName(stuName){per
2、Count++;cout<<"构造:"<3、private:stringszName;staticunsignedintperCount;};unsignedintPerson::perCount=0;intmain(intargc,char**argv){Person*p1=newPerson("Liu");Personp2("Li");Person*p3=newPerson(p2);deletep1;deletep3;}2./*STL中链表类list的部分成员函数注释如下:Thesort()functionisusedtosortlist4、sintoascendingorder.Orderingisdoneviathe5、d,thenitisusedasthecomparisonfunctionforthelistsinsteadof<.Thefunctionunique()removesallconsecutiveduplicateelementsfromthelist.Notethatonlyconsecutiveduplicatesareremoved,whichmayrequirethatyousort()thelistfirst.Equalityistestedusingthe==operator,unle6、ssprisspecifiedasareplacement.Theorderingoftheelementsinalistshouldnotchangeafteracalltounique().*/#include#include#includeusingnamespacestd;structStuNode{stringname;intID;StuNode(string_name="",int_ID=0):name(_name),ID(_ID){}fr7、iendbooloperator==(constStuNode&l,constStuNode&r){return(l.ID==r.ID);}friendbooloperator<(constStuNode&l,constStuNode&r){return(l.ID&buff){for(inti=0;i8、tlist&buff){list::const_iteratorit;for(it=buff.begin();it!=buff.end();it++)cout<ID<<"t"<name<
3、private:stringszName;staticunsignedintperCount;};unsignedintPerson::perCount=0;intmain(intargc,char**argv){Person*p1=newPerson("Liu");Personp2("Li");Person*p3=newPerson(p2);deletep1;deletep3;}2./*STL中链表类list的部分成员函数注释如下:Thesort()functionisusedtosortlist
4、sintoascendingorder.Orderingisdoneviathe5、d,thenitisusedasthecomparisonfunctionforthelistsinsteadof<.Thefunctionunique()removesallconsecutiveduplicateelementsfromthelist.Notethatonlyconsecutiveduplicatesareremoved,whichmayrequirethatyousort()thelistfirst.Equalityistestedusingthe==operator,unle6、ssprisspecifiedasareplacement.Theorderingoftheelementsinalistshouldnotchangeafteracalltounique().*/#include#include#includeusingnamespacestd;structStuNode{stringname;intID;StuNode(string_name="",int_ID=0):name(_name),ID(_ID){}fr7、iendbooloperator==(constStuNode&l,constStuNode&r){return(l.ID==r.ID);}friendbooloperator<(constStuNode&l,constStuNode&r){return(l.ID&buff){for(inti=0;i8、tlist&buff){list::const_iteratorit;for(it=buff.begin();it!=buff.end();it++)cout<ID<<"t"<name<
5、d,thenitisusedasthecomparisonfunctionforthelistsinsteadof<.Thefunctionunique()removesallconsecutiveduplicateelementsfromthelist.Notethatonlyconsecutiveduplicatesareremoved,whichmayrequirethatyousort()thelistfirst.Equalityistestedusingthe==operator,unle
6、ssprisspecifiedasareplacement.Theorderingoftheelementsinalistshouldnotchangeafteracalltounique().*/#include#include#includeusingnamespacestd;structStuNode{stringname;intID;StuNode(string_name="",int_ID=0):name(_name),ID(_ID){}fr
7、iendbooloperator==(constStuNode&l,constStuNode&r){return(l.ID==r.ID);}friendbooloperator<(constStuNode&l,constStuNode&r){return(l.ID&buff){for(inti=0;i8、tlist&buff){list::const_iteratorit;for(it=buff.begin();it!=buff.end();it++)cout<ID<<"t"<name<
8、tlist&buff){list::const_iteratorit;for(it=buff.begin();it!=buff.end();it++)cout<ID<<"t"<name<
此文档下载收益归作者所有