windows编程-windows编程实验一3

windows编程-windows编程实验一3

ID:41594226

大小:56.91 KB

页数:4页

时间:2019-08-28

windows编程-windows编程实验一3_第1页
windows编程-windows编程实验一3_第2页
windows编程-windows编程实验一3_第3页
windows编程-windows编程实验一3_第4页
资源描述:

《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♦include

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

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。