| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 389 人关注过本帖
标题:c++编程使用派生类出现如下错误怎么回事啊
取消只看楼主 加入收藏
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
结帖率:88.89%
收藏
已结贴  问题点数:20 回复次数:2 
c++编程使用派生类出现如下错误怎么回事啊
#include<iostream>
#include<string>
using namespace std;
class student
{private:
int num;
string name;
char sex;
public:
void get_value()
{cout<<"num,name,sex:"<<"\t";
cin>>num>>name>>sex;}
void display()
{cout<<"num"<<"\t"<<"name"<<"\t"<<"sex"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<ednl;

};
class student1:public student
{
private:
    int age;
    string addr;
public:
void get_value_1()
{cout<<"enter age,addr:"<<endl;
cin>>age>>addr;}
void display_1()
{cout<<"num:"<<"\t"<<"name"<<"\t"<<"sex"<<"\t"<<"age"<<"\t"<<"address"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<"\t"<<age<<"\t"<<addr<<endl;
}

};
int main()
{student1 stud;
stud.get_value();
stud.get_value_1();
stud.display();
stud.display_1();
return 0;
}


错误如下:
Compiling...
c++xiti2.cpp
C:\编程\Visual+C+++6.0(支持win7)\Microsoft Visual Studio\Common\MSDev98\Bin\c++xiti2.cpp(19) : error C2504: 'student' : base class undefined
C:\编程\Visual+C+++6.0(支持win7)\Microsoft Visual Studio\Common\MSDev98\Bin\c++xiti2.cpp(41) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
搜索更多相关主题的帖子: private display include public 
2015-11-12 09:03
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
?不懂

唯望君安~
2015-11-12 09:23
winner1995
Rank: 2
等 级:论坛游民
帖 子:64
专家分:41
注 册:2015-10-11
收藏
得分:0 
ok了  
#include<iostream>
#include<string>
using namespace std;
class student
{private:
int num;
string name;
char sex;
public:
void get_value()
{cout<<"num,name,sex:"<<"\t";
cin>>num>>name>>sex;}
void display()
{cout<<"num"<<"\t"<<"name"<<"\t"<<"sex"<<endl;
cout<<num<<"\t"<<name<<"\t"<<sex<<endl;}
};
class student1:public student
{
private:
    int age;
    string addr;
public:
void get_value_1()
{cout<<"enter age,addr:"<<endl;
cin>>age>>addr;}
void display_1()
{cout<<"age"<<"\t"<<"address"<<endl;
cout<<"\t"<<age<<"\t"<<addr<<endl;
}

};
int main()
{student1 stud;
stud.get_value();
stud.get_value_1();
stud.display();
stud.display_1();
return 0;
}

唯望君安~
2015-11-12 09:26
快速回复:c++编程使用派生类出现如下错误怎么回事啊
数据加载中...
 
   



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

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