| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 461 人关注过本帖
标题:怎么运行出错
只看楼主 加入收藏
nan1888
Rank: 2
等 级:论坛游民
帖 子:44
专家分:86
注 册:2011-6-19
结帖率:85.71%
收藏
 问题点数:0 回复次数:1 
怎么运行出错
#include  <iostream>
#include<string>
using namespace std;
class people
{ public:
char name[20];
int num;
int sex;
int num1;

people()
{num=0;
sex=0;
num1=0;
strcpy(name,"no name");
}
void set()
{cout<<"姓名"<<endl;
cin>>name;
cout<<"编号"<<endl;
cin>>num;
cout<<"性别"<<endl;
cin>>sex;
cout<<"身份证号"<<endl;
cin>>num1;
}
void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
}
};



class student:virtual public people
{
public:
int sumtime4;
int weektime;
student():people()
{sumtime4=0;
weektime=0;}
void set()
{people::set();
cout<<"总学时数"<<endl;
cin>>sumtime4;
cout<<"周学时数"<<endl;
cin>>weektime;}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime4<<endl;
cout<<"周学时数"<<weektime<<endl;}
};


class teacher:virtual public people

{public:
int teachtime;
int sumteach4;
teach():people()
{teachtime=0;
sumteach4=0;}
void set()
{people::set;
cout<<"总学时数"<<<<endl;
cin>>sumteach4;
cout<<"周学时数"<<<<endl;
cin>>teachtime;}
void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<teachtime<<endl;
cout<<"周学时数"<<sumteach4<<endl;}
};


class graduate: virtual public student
{public:
int yantime;
int sumtime;
graduate():student()

{
yantime=0;
sumtime=0;
}
void set()
{student::set();
cout<<"周研究时间"<<endl;
cin>>yantime;
cout<<"总研究时间"<<endl;
cin>>sumtime;}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime<<endl;
cout<<"周学时数"<<weektime<<endl;
cout<<"周研究时间"<<yantime<<endl;
cout<<"总研究时间"<<sumtime<<endl;
};
//添加程序

class TA:public  student,public teacher
{public:
int yantime;
int sumtime2;
TA():student():teacher()

{yantime=0;
sumtime=0;}
void set()
{cout<<"姓名"<<endl;
cin>>name;
cout<<"编号"<<endl;
cin>>num;
cout<<"性别"<<endl;
cin>>sex;
cout<<"身份证号"<<endl;
cin>>num1;
cout<<"总学时数"<<endl;
cin>>sumtime4;
cout<<"周学时数"<<endl;
xin>>weektime;
cout<<"周研究时间"<<endl;
cin>>yantime;

cout<<"总研究时间"<<endl;
cin>>sumtime2;
cout<<"周教学时间"<<endl
cin>>teachtime;
cout<<"总教学时间"<<endl;
cin>>sumtime;}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime<<endl;
cout<<"周学时数"<<weektime<<endl;
cout<<"周研究时间"<<yantime<<endl;
cout<<"总研究时间"<<sumtime<<endl;
cout<<"周教学时间"<<teachtime<<endl;
cout<<"总教学时间"<<sumteach4<<endl;};

};
void main()
{teacher fgh();
fgh.set();
fgh.show;
}
搜索更多相关主题的帖子: 姓名 people 身份证号 
2011-06-30 20:42
吴辉
Rank: 3Rank: 3
来 自:湖南
等 级:论坛游侠
帖 子:52
专家分:199
注 册:2011-3-27
收藏
得分:0 
#include  <iostream>
#include<string>
using namespace std;

class people
{ public:
char name[20];
int num;
int sex;
int num1;

 people()
  {
    num=0;
    sex=0;
    num1=0;
    strcpy(name,"no name");
 }
 void set()
 {cout<<"姓名"<<endl;
cin>>name;
cout<<"编号"<<endl;
cin>>num;
cout<<"性别"<<endl;
cin>>sex;
cout<<"身份证号"<<endl;
cin>>num1;
 }
  void show()
  {cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
  }
};



class student:virtual public people
{
public:
int sumtime4;
int weektime;
    student():people()
    {sumtime4=0;
      weektime=0;}

    void set()
{people::set();
cout<<"总学时数"<<endl;
cin>>sumtime4;
cout<<"周学时数"<<endl;
cin>>weektime;}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime4<<endl;
cout<<"周学时数"<<weektime<<endl;}
};


class teacher:virtual public people

{public:
int teachtime;
int sumteach4;
teacher():people()         //原程序这里的teach():people()应该是teacher():people()

{
    teachtime=0;
    sumteach4=0;
}

void set()
{people::set();             //原程序中少了()
cout<<"总教时数"<<endl;     //原程序中这里多个<<
cin>>sumteach4;
cout<<"周学时数"<<endl;    //原程序中这里多个<<

cin>>teachtime;
}
void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<teachtime<<endl;
cout<<"周学时数"<<sumteach4<<endl;}
};


class graduate: virtual public student
{public:
int yantime;
int sumtime;
graduate():student()

{
yantime=0;
sumtime=0;
}
void set()
{student::set();
cout<<"周研究时间"<<endl;
cin>>yantime;
cout<<"总研究时间"<<endl;
cin>>sumtime;}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime<<endl;
cout<<"周学时数"<<weektime<<endl;
cout<<"周研究时间"<<yantime<<endl;
cout<<"总研究时间"<<sumtime<<endl;}      //原程序这里少个 }
};
//添加程序

class TA:public  student,public teacher
{public:
int yantime;
int sumtime2;
TA():student(),teacher()       //原程序TA():student():teacher()改成TA():student(),teacher()

{yantime=0;
sumtime2=0;}                  //原程序中的sumtime改成sumtime2
void set()
{cout<<"姓名"<<endl;
cin>>name;
cout<<"编号"<<endl;
cin>>num;
cout<<"性别"<<endl;
cin>>sex;
cout<<"身份证号"<<endl;
cin>>num1;
cout<<"总学时数"<<endl;
cin>>sumtime4;
cout<<"周学时数"<<endl;
cin>>weektime;                         //原程序中cin写错
cout<<"周研究时间"<<endl;
cin>>yantime;

cout<<"总研究时间"<<endl;
cin>>sumtime2;
cout<<"周教学时间"<<endl;            //原程序这里少了  ;
cin>>teachtime;
cout<<"总教学时间"<<endl;
cin>>sumteach4;                               //这里的sumtime应该是sumtime4
}

void show()
{cout<<"姓名"<<name<<endl;
cout<<"编号"<<num<<endl;
cout<<"性别"<<sex<<endl;
cout<<"身份证号"<<num1<<endl;
cout<<"总学时数"<<sumtime4<<endl;      //原程序中sumtime应该是sumtime4
cout<<"周学时数"<<weektime<<endl;
cout<<"周研究时间"<<yantime<<endl;
cout<<"总研究时间"<<sumtime2<<endl;    //原程序中的sumtime应该是sumtime2
cout<<"周教学时间"<<teachtime<<endl;
cout<<"总教学时间"<<sumteach4<<endl;
}

};


void  main()
{
    teacher fgh;             //原程序定义对象多了个 ()
    fgh.set();
    fgh.show();             //原程序fgh.show改成fgh.show()

}



运行下,看看是不是你要的结果。
2011-07-14 11:17
快速回复:怎么运行出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017535 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved