| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 547 人关注过本帖
标题:找不到错误所在?
只看楼主 加入收藏
魔鬼之子
Rank: 1
来 自:地狱之都
等 级:新手上路
帖 子:100
专家分:0
注 册:2007-9-22
结帖率:71.43%
收藏
已结贴  问题点数:5 回复次数:3 
找不到错误所在?
# include<iostream>
using namespace std;

class Teacher{
    int tn;
    char *pt;
    char *ml;
public:
    void SetTN(int tn);
    void SetPT(char *pt);
    void SetML(char *ml);
    int GetTN();
    char *GetPT();
    char *GetML();
};

class Student{
    int sn;
    char *sf;
    char *grade;
public:
    void SetSN(int sn);
    void SetSF(char *sf);
    void SetGRADE(char *grade);
    int GetSN();
    char *GetSF();
    char *GetGRADE();
};

class PostGraduate:public Teacher,public Student{
    char *name;
    int age;
public:
    void SetName(char *name);
    void SetAge(int age);
    char *GetName();
    int GetAge();
};

void Teacher::SetTN(int tn){
    this->tn=tn;
}
void Teacher::SetPT(char *pt){
    this->pt=pt;
}
void Teacher::SetML(char *ml){
    this->ml=ml;
}
int Teacher::GetTN(){
    return this->tn;
}
char *Teacher::GetPT(){
    return this->pt;
}
char *Teacher::GetML(){
    return this->ml;
}

void Student::SetSN(int sn){
    this->sn=sn;
}
void Student::SetSF(char *sf){
    this->sf=sf;
}
void Student::SetGRADE(char *grade){
    this->grade=grade;
}
int Student::GetSN(){
    return this->sn;
}
char *Student::GetSF(){
    return this->sf;
}
char *Student::GetGRADE{
    return this->grade;
}

void PostGraduate::SetName(char *name){
    this->name=name;
}
void PostGraduate::SetAge(int age){
    this->age=age;
}
char *PostGraduate::GetName(){
    return this->name;
}
int PostGraduate::GetAge(){
    return this->age;
}

void main(){
    int sn,tn,age;
    char *pt,*ml,*sf,*grade,*name;
    PostGraduate pg;

    cout<<"请输入学号:"<<endl;
    cin>>sn;
    cout<<"请输入教工号:"<<endl;
    cin>>tn;
    cout<<"请输入姓名:"<<endl;
    cin>>name;
    cout<<"请输入年龄:"<<endl;
    cin>>age;
    cout<<"请输入班级:"<<endl;
    cin>>grade;
    cout<<"请输入专业:"<<endl;
    cin>>sf
    cout<<"请输入主修课程:"<<endl;
    cin>>ml
    cout<<"请输入职称:"<<endl;
    cin>>pt;

    pg.Student::SetSN(sn);
    pg.Teacher::SetTN(tn);
    pg.SetName(name);
    pg.SetAge(age);
    pg.Student::SetGRADE(grade);
    pg.Student::SetSF(sf);
    pg.Teacher::SetML(ml);
    pg.Teacher::SetPT(pt);

    cout<<pg.Student::GetSN()<<endl;
    cout<<pg.Teacher::GetTN()<<endl;
    cout<<pg.GetName()<<endl;
    cout<<pg.GetAge()<<endl;
    cout<<pg.Student::GetGRADE()<<endl;
    cout<<pg.Student::GetSF()<<endl;
    cout<<pg.Teacher::GetML()<<endl;
    cout<<pg.Teacher::GetPT()<<endl;
}
编译后:
--------------------Configuration: PostGraduateObject - Win32 Debug--------------------
Compiling...
PostGraduateClass.cpp
F:\vc++\vc++程序\MyObject\PostGraduateObject\PostGraduateClass.cpp(74) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'msc1.cpp', line 1786)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.

PostGraduateClass.obj - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: void include public 
2009-11-03 22:18
qlc00
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:2
帖 子:157
专家分:540
注 册:2007-11-26
收藏
得分:5 
# include<iostream>
using namespace std;

class Teacher{
    int tn;
    char *pt;
    char *ml;
public:
    void SetTN(int tn);
    void SetPT(char *pt);
    void SetML(char *ml);
    int GetTN();
    char *GetPT();
    char *GetML();
};

class Student{
    int sn;
    char *sf;
    char *grade;
public:
    void SetSN(int sn);
    void SetSF(char *sf);
    void SetGRADE(char *grade);
    int GetSN();
    char *GetSF();
    char *GetGRADE();
};

class PostGraduate:public Teacher,public Student{
    char *name;
    int age;
public:
    void SetName(char *name);
    void SetAge(int age);
    char *GetName();
    int GetAge();
};

void Teacher::SetTN(int tn){
    this->tn=tn;
}
void Teacher::SetPT(char *pt){
    this->pt=pt;
}
void Teacher::SetML(char *ml){
    this->ml=ml;
}
int Teacher::GetTN(){
    return this->tn;
}
char *Teacher::GetPT(){
    return this->pt;
}
char *Teacher::GetML(){
    return this->ml;
}

void Student::SetSN(int sn){
    this->sn=sn;
}
void Student::SetSF(char *sf){
    this->sf=sf;
}
void Student::SetGRADE(char *grade){
    this->grade=grade;
}
int Student::GetSN(){
    return this->sn;
}
char *Student::GetSF(){
    return this->sf;
}
char *Student::GetGRADE(){//这里少一对括号
    return this->grade;
}

void PostGraduate::SetName(char *name){
    this->name=name;
}
void PostGraduate::SetAge(int age){
    this->age=age;
}
char *PostGraduate::GetName(){
    return this->name;
}
int PostGraduate::GetAge(){
    return this->age;
}

void main(){
    int sn,tn,age;
    char *pt,*ml,*sf,*grade,*name;
    PostGraduate pg;

    cout<<"请输入学号:"<<endl;
    cin>>sn;
    cout<<"请输入教工号:"<<endl;
    cin>>tn;
    cout<<"请输入姓名:"<<endl;
    cin>>name;
    cout<<"请输入年龄:"<<endl;
    cin>>age;
    cout<<"请输入班级:"<<endl;
    cin>>grade;
    cout<<"请输入专业:"<<endl;
    cin>>sf ;//这里少一个分号
    cout<<"请输入主修课程:"<<endl;
    cin>>ml;//这里少一个分号
    cout<<"请输入职称:"<<endl;
    cin>>pt;

    pg.Student::SetSN(sn);
    pg.Teacher::SetTN(tn);
    pg.SetName(name);
    pg.SetAge(age);
    pg.Student::SetGRADE(grade);
    pg.Student::SetSF(sf);
    pg.Teacher::SetML(ml);
    pg.Teacher::SetPT(pt);

    cout<<pg.Student::GetSN()<<endl;
    cout<<pg.Teacher::GetTN()<<endl;
    cout<<pg.GetName()<<endl;
    cout<<pg.GetAge()<<endl;
    cout<<pg.Student::GetGRADE()<<endl;
    cout<<pg.Student::GetSF()<<endl;
    cout<<pg.Teacher::GetML()<<endl;
    cout<<pg.Teacher::GetPT()<<endl;
}

Anything is possible!
2009-11-03 22:29
魔鬼之子
Rank: 1
来 自:地狱之都
等 级:新手上路
帖 子:100
专家分:0
注 册:2007-9-22
收藏
得分:0 
回复 2楼 qlc00
谢谢你的帮助!

只有仇恨才是永恒的
2009-11-03 23:06
qlc00
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:2
帖 子:157
专家分:540
注 册:2007-11-26
收藏
得分:0 
回复 3楼 魔鬼之子
不客气!

Anything is possible!
2009-11-03 23:19
快速回复:找不到错误所在?
数据加载中...
 
   



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

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