| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 769 人关注过本帖
标题:C++新手,完成老师布置的作业,练习多重继承,代码出现错误,弄半天弄不懂, ...
取消只看楼主 加入收藏
a853052879
Rank: 2
等 级:论坛游民
帖 子:39
专家分:10
注 册:2015-8-17
结帖率:60%
收藏
已结贴  问题点数:20 回复次数:0 
C++新手,完成老师布置的作业,练习多重继承,代码出现错误,弄半天弄不懂,求大神指教
#include<iostream>
#include<string>
using namespace std;
Class Date
{
    public:
        Date(int Nian,int Yue,int Ri)
        {
            nian=Nian;
            yue=Yue;
            ri=Ri;
        }
        void display()
        {
        cout<<nian<<" "<<yue<<" "<<ri<<endl;
        }
        private:
            int nian;
            int yue;
            int ri;
};

Class Time
{
    public:
        Time(int Shi,int Fen,int Miao){Shi=shi;Fen=fen;Miao=miao;}
        void display1()
        {
            cout<<shi<<":"<<fen<<":"<<miao<<endl;
        }
        private:
            int shi;
            int fen;
            int miao;
};

Class Week:public Date,public Time
{
    public:
        Week(int Nian,int Yue,int Ri,int Shi,int Fen,int Miao,string xq):
        Date(Nian,Yue,Ri),Time(Shi,Fen,Miao)
        void show()
        {
            cout<<Nian<<" "<<Yue<<" "<<Ri<<endl;
            cout<<Shi<<":"<<Fen<<":"<<Miao<<endl;
            cout<<xq<<endl;
        }
    private:
        string xq;
        };
int main()
{
    Week week(2015,11,11,22,43,50,"xqs");
    week.show();
    return 0;
}
代码出现如下错误:D:\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(5) : error C2146: syntax error : missing ';' before identifier 'Date'
D:\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(5) : error C2501: 'Class' : missing storage-class or type specifiers
D:\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(5) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
求大牛指教!!!1
搜索更多相关主题的帖子: private display include public 
2015-11-11 23:08
快速回复:C++新手,完成老师布置的作业,练习多重继承,代码出现错误,弄半天弄 ...
数据加载中...
 
   



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

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