| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:各位大师,看看错在哪
只看楼主 加入收藏
张堪绘
Rank: 1
等 级:新手上路
帖 子:15
专家分:6
注 册:2013-4-13
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:1 
各位大师,看看错在哪
#include<iostream>
using namespace std;
class person{
public:
    person(int number1,string name1)
    {number=number1;
    name=name1;}
    void print()
    {cout<<"编号:"<<number<<endl;
    cout<<"姓名:"<<name<<endl;
    }
protected:
    long number;
    string name;
};
class student:virtual public person{
public:
    student(int number1,string name1,int class_number1,float score1):person(number1,name1)
    {class_number=class_number1;
    score=score1;}
    void print()
    {person::print()
    cout<<"班号:"<<class_number<<endl;
    cout<<"成绩:"<<score<<endl;}
protected:
    int class_number;
    float score;};
    class teacher:virtual public person{
    public:
        teacher(int number1,string name1,srting work1,string dept1):person(number1,name1)
        {work=work1;
        dept=dept1;}
        void print()
        {person::print();
        cout<<"职称:"<<work<<endl;
        cout<<"部门:"<<dept<<enddl;}
    protected:
        string work;
        string dept;};
        int main()
        {student stud1(12115021058,"张三",12,89);
        cout<<"学生:"<<endl;
stud1.print();
teacher stud2(12115021059,"李四","老师","英语系");
cout<<"老师:"<<endl;
              stud2.print();
return 0;}
搜索更多相关主题的帖子: name void include person public 
2013-05-02 23:42
邓士林
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:淮河河畔
等 级:贵宾
威 望:61
帖 子:2392
专家分:13384
注 册:2013-3-3
收藏
得分:20 
首先没有包含string类的头文件,应该加上 #include<string>;
其次class student:virtual public person{
public:
    student(int number1,string name1,int class_number1,float score1):person(number1,name1)
    {class_number=class_number1;
    score=score1;}
    void print()
    {person::print()
    cout<<"班号:"<<class_number<<endl;
    cout<<"成绩:"<<score<<endl;}
红色处少了分号;
最后的问题
teacher stud2(12115021059,"李四","老师","英语系");
后面的括号和分号你写成中文的啦,改成英文的就ok啦

Maybe
2013-05-03 10:10
快速回复:各位大师,看看错在哪
数据加载中...
 
   



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

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