欢迎来到天天文库
浏览记录
ID:41594226
大小:56.91 KB
页数:4页
时间:2019-08-28
《windows编程-windows编程实验一3》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、Windows编程实验一姓名:卢建斌班级:计科1303学号:20133102003131、开发环境搭建:(1)参考附件《实验讲义》中第一个实验文档,配置QtCreater2.8.1和Q4.8.5开发环境。(2)参考第二个实验文档,创建HelloWorld应用。(3)根据以上经验,自己创建一个控制台程序项目。然后,参考附件family_relationship项目,完成:1、试错练习。至少归纳出3个编译器报错的可能情况,总结在以下空白处。1.e:QTQtsorkspacelfather.h:14:错误:'string'doesnotnameatypestring不是一个类型的名字
2、2.e:QTQtsorkspacelchild.cpp:16:错误:requestformember'answer'in,((Child*)this)->Child::father,,whichisofnon-classtype'Father**没有指针类型应该使用3.e:QTQtsorkspacelfather.h:8:辛昔误:'sd'isnotanamespace-namest不是命名空间的名字4.e:QTQtsorkspace1father.h:8:luexpectednamespace-namebeforeVtoken命名空间没有包含进來2、为Child
3、类增添代码,时Child也能呼叫Fathero尝试若不使用前置声明方法,或者不使用指针数据成员,或者不初始化对象中的指针成员时,可能出现的各种编译器报错或运行期错误。1.E:QTQtsorkspacefamily_relationshipchild.h:l3:错误:field'father'hasincompletetypefather是一个不完全类型2.e:QTQtsorkspacelchild.cpp:16:错误:invaliduseofincompletetype'structFather'编译器不知道所用的struct或者是class的具体实现也就是说要使用的那
4、个.h文件没有包含进来3.e:QTQtsorkspace1child.h:6:错误:forwarddeclarationof'structFather'没有加father.h头文件4.E:QTQtsorkspacefamily_relationshipchild.h:14:错误:ISOC++forbidsdeclarationof'Father1withnotype当father.cpp、child.cpp两个文件,分别包含了对方的头文件,并旦分别又在自己的类中声明了对象3、写Mother类代码,探索是否只能够釆用前置声明和指针数据成员相结合的编程技术,尝试用两种不同编
5、程技术实现Mother•类和Child类。方法一:mother,h#ifndefMOTHER_H#defineMOTHER_H#includeusingnamespacestd;#include"child・hHclassMother{public:Mother();stringname;Child*child;voidcallChild();voidanswer();};#endif//MOTHER」mother・cpp#includenmother•h11♦include6、(11HuaHua11){child=newChild();child->mother=this;}voidMother::callChildO{coutvvendlvv”]amcallingmychild!H;child->answer();}voidMother::answer(){coutusingnamespacestd;//#include11chiId・h"classChild;classMother{p7、ublic:Mother();stringname;Child*child;voidcallChild();voidanswer();};#endif//MOTHER_Hmother・cpp//#include"mother・h”♦include#include"child・h”#includeclassMother;Mother::Mother():name(nHuaHuan){child=newChild
6、(11HuaHua11){child=newChild();child->mother=this;}voidMother::callChildO{coutvvendlvv”]amcallingmychild!H;child->answer();}voidMother::answer(){coutusingnamespacestd;//#include11chiId・h"classChild;classMother{p
7、ublic:Mother();stringname;Child*child;voidcallChild();voidanswer();};#endif//MOTHER_Hmother・cpp//#include"mother・h”♦include#include"child・h”#includeclassMother;Mother::Mother():name(nHuaHuan){child=newChild
此文档下载收益归作者所有