| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 724 人关注过本帖
标题:求高手帮忙改错下,急啊!!!(不明白错误什么意思)
取消只看楼主 加入收藏
px200
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-4-16
结帖率:60%
收藏
已结贴  问题点数:10 回复次数:2 
求高手帮忙改错下,急啊!!!(不明白错误什么意思)
#include<iostream>
#include<string>
using namespace std;
class Date{
public:
    Date();
    Date(char *name,int x,char y,int m,int e,int c,int co);
    void setdate(char *name,int x,char y,int m,int e,int c,int z);
    void showstudent();
    void aver(int Average,int m,int e,int c,int z);
private:
    string Name;
    int ID;
    char Sex;
    int Math;
    int English;
    int C;
    int Computer;
    int Average;
   
};
Date::setdate(char *name,int x,char y,int m,int e,int c,int z)
{
 name=new char[10];
 cin>>name>>x>>y>>m>>e>>c>>z;
 delete []name;
}
Date::Date()
{}
void Date::showstudent()
{cout<<Name<<"  "<<ID<<"  "<<Sex<<"  "<<Math<<"  "<<English<<"  "<<C<<"  "<<Computer<<" "<<Average<<endl;}
void Date::aver(int Average,int m,int e,int c,int co)
{
    Average=(m+e+c+co)/4;
}
Date::Date(char *name,int x,char y,int m,int e,int c,int z)
{
    Name=name;
    ID=x;
    Sex=y;
    Math=m;
    English=e;
    C=c;
    Computer=z;
}


int main()
{
    int q;
    cout<<"Please Input the Number of Students:"<<endl;
    cin>>q;
    cout<<"Please input"<<" "<<q<<" "<<"student info: Name  ID  Sex  Math  English  C  Computer"<<endl;
    Date *stu=new Date[q];
    for(int j=0;j<q;j++)
    {
        stu[j].setdate();
    }
    cout<<endl<<"Student Information you input:"<<endl;
    cout<<"Name  ID  Sex  Math  English  C  Computer  Average"<<endl;
    for(int i=0;i<q;i++)
    {
        stu[i].showstudent();
    }
    delete []stu;
    return 0;
}


下面这是错误提示信息
D:\VC++\program work\program work\lab5\lab-5.cpp(23) : error C2556: 'int __thiscall Date::setdate(char *,int,char,int,int,int,int)' : overloaded function differs only by return type from 'void __thiscall Date::setdate(char *,int,char,int,int,int,int
)'
        D:\VC++\program work\program work\lab5\lab-5.cpp(8) : see declaration of 'setdate'
D:\VC++\program work\program work\lab5\lab-5.cpp(23) : error C2371: 'setdate' : redefinition; different basic types
        D:\VC++\program work\program work\lab5\lab-5.cpp(8) : see declaration of 'setdate'
D:\VC++\program work\program work\lab5\lab-5.cpp(57) : error C2660: 'setdate' : function does not take 0 parameters
Error executing cl..obj - 3 error(s), 0 warning(s)
搜索更多相关主题的帖子: namespace void English private include 
2013-04-17 21:41
px200
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-4-16
收藏
得分:0 
回复 2楼 邓士林
#include<iostream>
#include<string>
using namespace std;
class Date{
public:
    Date();
    Date(char *name,int x,char y,int m,int e,int c,int z);
    void setdate(char *name,int x,char y,int m,int e,int c,int z);
    void showstudent();
    void aver(int Average,int m,int e,int c,int z);
private:
    string Name;
    int ID;
    char Sex;
    int Math;
    int English;
    int C;
    int Computer;
    int Average;
   
};
void Date::setdate(char *name,int x,char y,int m,int e,int c,int z)
{
 name=new char[10];
 cin>>name>>x>>y>>m>>e>>c>>z;
 delete []name;
}
Date::Date()
{}
void Date::showstudent()
{cout<<Name<<"  "<<ID<<"  "<<Sex<<"  "<<Math<<"  "<<English<<"  "<<C<<"  "<<Computer<<" "<<Average<<endl;}
void Date::aver(int Average,int m,int e,int c,int z)
{
    Average=(m+e+c+z)/4;
}
Date::Date(char *name,int x,char y,int m,int e,int c,int z)
{
    Name=name;
    ID=x;
    Sex=y;
    Math=m;
    English=e;
    C=c;
    Computer=z;
}


int main()
{
    int q;
    cout<<"Please Input the Number of Students:"<<endl;
    cin>>q;
    cout<<"Please input"<<" "<<q<<" "<<"student info: Name  ID  Sex  Math  English  C  Computer"<<endl;
    Date *stu=new Date[q];
    for(int j=0;j<q;j++)
    {
        stu[j].setdate(char *name,int x,char y,int m,int e,int c,int z);
    }
    cout<<endl<<"Student Information you input:"<<endl;
    cout<<"Name  ID  Sex  Math  English  C  Computer  Average"<<endl;
    for(int i=0;i<q;i++)
    {
        stu[i].showstudent();
    }
    delete []stu;
    return 0;
}


这是我改过的,但又出来下面这三个错,我刚学C++不明白,求指教
D:\VC++\program work\program work\lab5\lab-5.cpp(57) : error C2144: syntax error : missing ')' before type 'char'
D:\VC++\program work\program work\lab5\lab-5.cpp(57) : error C2660: 'setdate' : function does not take 0 parameters
D:\VC++\program work\program work\lab5\lab-5.cpp(57) : error C2059: syntax error : ')'
Error executing cl.exe.

lab-5.exe - 3 error(s), 0 warning(s)
2013-04-18 08:12
px200
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2013-4-16
收藏
得分:0 
回复 5楼 zhuxiaoneng
恩 对了 非常感谢!
2013-04-18 13:14
快速回复:求高手帮忙改错下,急啊!!!(不明白错误什么意思)
数据加载中...
 
   



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

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