实验5人员类的设计与实现VisualC++程序设计实验报告 下载本文

{

student.Output(); for(int i=0;i<3;i++)

cout<<\成绩\ }//类CTeacher实现代码

CTeacher::CTeacher(char*name,char*id,bool isman,int years) {

nTeachYears=years; Input(name,id,isman); }

void CTeacher::Print() {

Output();

cout<<\教龄: \ }

void main() {

CStudent stu(\李明亮\ cout<

cout<

stu.student.setName(\李明亮2\ stu.student.setSex(1); stu.InputScore(80,90,85); stu.Print();

CTeacher tea(\赵永进\ tea.setID(\ tea.Print(); } (2)单击标准工具栏的“save”按钮,弹出“保存为”文件对话框。将文件保存为Ex_Class.cpp。 (3)编译运行

(4)选择“工程”→“添加到工程”→“文件”菜单命令,在弹出的“插入文件到工程”对话框中,选定前面的文件Ex_class.h,单击“确定”按钮,此时的开发环境如图。

4、退出Visual C++6.0 结果分析与总结

代码输入时要耐心、细心。注意不能把“.”误输入为“,”,比如包含头文件时把输入为这样一般很难辨别,这样的错误都很难查找。

不能画蛇添足,比如double score1,double score2,double score3不能改为double score 1,double score 2,double score 3,不然都会报错的。 教师签名: