| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 972 人关注过本帖
标题:【求助】帮忙改下错误!
只看楼主 加入收藏
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
 问题点数:0 回复次数:9 
【求助】帮忙改下错误!
#include<iostream.h>
#include<string.h>
class Student
{
        float ID;
        char NAME[20];
        char SEX[10];
        int SCORE[6];


public:
 Student(float id=1,char *name="譁鄵",char *sex="男",int score1=0,int score2=0,int score3=0,int score4=0,int score5=0)

  {
                ID=id;
                strcpy(NAME,name);
                strcpy(SEX,sex);
                SCORE[0]=0;
                SCORE[2]=1;
                SCORE[3]=2;
                SCORE[4]=3;
                SCORE[5]=4;
   
        }
 int SCORE(int z)
{
 int a,b,c,d,e,sum;
 if(z==1)
 {a=90;b=80;c=70;d=50;e=99;}
    if(z==2)
 {a=77;b=84;c=72;d=13;e=56;}
 if(z==3)
 {a=77;b=23;c=100;d=15;e=32;}
 if(z==4)
 {a=87;b=45;c=75;d=65;e=55;}
 if(z==5)
 {a=74;b=85;c=85;d=64;e=46;}
 if(z==6)
 {a=66;b=87;c=95;d=67;e=75;}
 if(z==7)
 {a=65;b=45;c=75;d=79;e=63;}
 if(z==8)
 {a=94;b=75;c=34;d=74;e=78;}
 {sum=a+b+c+d+e;}
 
void name(int x)               
{
 if(x==1) cout<<"姓名:譁鄵"<<endl;
 if(x==2) cout<<"姓名:詉庅枏"<<endl;
 if(x==3) cout<<"姓名:脦塍蓲"<<endl;
 if(x==4) cout<<"姓名:虠轑鲻"<<endl;
 if(x==5) cout<<"姓名:醟朙籩"<<endl;
 if(x==6) cout<<"姓名:臡鼐孻"<<endl;
 if(x==7) cout<<"姓名:恴赨"<<endl;
 if(x==8) cout<<"姓名:絼躢閁鍀"<<endl;
}
void sex(int y)
{
 if(y==1) cout<<"男"<<endl;
 if(y==2) cout<<"女"<<endl;
 if(y==3) cout<<"男"<<endl;
 if(y==4) cout<<"男"<<endl;
 if(y==5) cout<<"女"<<endl;
 if(y==6) cout<<"男"<<endl;
 if(y==7) cout<<"女"<<endl;
 if(y==8) cout<<"男"<<endl;
}
};

int main()
{
for(int i=0;i<=7;i++)
     cout<<"=============================="<<endl;   
  cout<<"1-8号学生成绩资料查询"<<endl;
  cout<<"\t"<<"学号:"<<ID<<endl;
     cout<<"\t"<<"姓名:"<<NAME<<endl;
     cout<<"\t"<<"性别:"<<SEX<<endl;
     cout<<"\t"<<"语文:"<<a<<"\t"<<"网络技术:"<<b<<endl;
  cout<<"\t"<<"C++:"<<c<<"\t"<<"数据库:"<<d<<endl;
  cout<<"\t"<<"photoshop: "<<e<<"\t"<<"总计: "<<sum<<endl;
  cout<<"=============================="<<endl;
  if(i>8 || i<1)
  return 0;
}
搜索更多相关主题的帖子: class include 
2007-12-08 13:41
afliult
Rank: 1
等 级:新手上路
帖 子:72
专家分:0
注 册:2007-7-22
收藏
得分:0 
Student(float id=1,char *name="譁鄵",char *sex="男",int score1=0,int score2=0,int score3=0,int score4=0,int score5=0)
改成
Student(float id,char *name,char *sex,int score1,int score2,int score3,int score4,int score5)
2007-12-09 09:28
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
不行啊,变量要付处值啊,还是有一处错误!
具体错误

--------------------Configuration: 改 - Win32 Debug--------------------
Compiling...
改.cpp
E:\c++\复件 c1\改.cpp(84) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

改.obj - 1 error(s), 0 warning(s)
2007-12-09 09:56
zhouxiang
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2007-10-16
收藏
得分:0 
主函数中for循环语句括号未加,此外main函数中要用对象调用,如;
Student stu;
stu.name(...);
私有成员变量不能直接调用,要好好看看C++书。
2007-12-09 18:22
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
帮忙调用下么,我实在整不来了,那么厚的书,看了就想打瞌睡!
2007-12-15 01:48
leon_smoker
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-12-18
收藏
得分:0 
这个程序是拿来做什么的?怎么看不出有什么用途`....
2007-12-18 15:42
lonmaor
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:郑州
等 级:版主
威 望:75
帖 子:2637
专家分:6423
注 册:2007-11-27
收藏
得分:0 
好特别的名字
2007-12-18 15:55
lovely123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2007-11-29
收藏
得分:0 
改来改去还是改不掉错误,现在多到12个了!
#include<iostream.h>
#include<string.h>
class Student
{private:
        float ID;
        char NAME[20];
        char SEX[10];
        int SCORE[6];


public:
    Student(float id=1,char *name="譁鄵",char *sex="男",int score1=0,int score2=0,int score3=0,int score4=0,int score5=0)

        {
                ID=id;
                strcpy(NAME,name);
                strcpy(SEX,sex);
                SCORE[1]=0;
                SCORE[2]=1;
                SCORE[3]=2;
                SCORE[4]=3;
                SCORE[5]=4;
                
        }
    int number(int z)
    {
    int a,b,c,d,e,sum;
    if(z==1)
    {a=90;b=80;c=70;d=50;e=99;}
    if(z==2)
    {a=77;b=84;c=72;d=13;e=56;}
    if(z==3)
    {a=77;b=23;c=100;d=15;e=32;}
    if(z==4)
    {a=87;b=45;c=75;d=65;e=55;}
    if(z==5)
    {a=74;b=85;c=85;d=64;e=46;}
    if(z==6)
    {a=66;b=87;c=95;d=67;e=75;}
    if(z==7)
    {a=65;b=45;c=75;d=79;e=63;}
    if(z==8)
    {a=94;b=75;c=34;d=74;e=78;}
    {sum=a+b+c+d+e;}
    }
    void name(int x)               
{
    if(x==1) cout<<"姓名:譁鄵"<<endl;
    if(x==2) cout<<"姓名:詉庅枏"<<endl;
    if(x==3) cout<<"姓名:脦塍蓲"<<endl;
    if(x==4) cout<<"姓名:虠轑鲻"<<endl;
    if(x==5) cout<<"姓名:醟朙籩"<<endl;
    if(x==6) cout<<"姓名:臡鼐孻"<<endl;
    if(x==7) cout<<"姓名:恴赨"<<endl;
    if(x==8) cout<<"姓名:絼躢閁鍀"<<endl;
}
    void sex(int y)
{
    if(y==1) cout<<"男"<<endl;
    if(y==2) cout<<"女"<<endl;
    if(y==3) cout<<"男"<<endl;
    if(y==4) cout<<"男"<<endl;
    if(y==5) cout<<"女"<<endl;
    if(y==6) cout<<"男"<<endl;
    if(y==7) cout<<"女"<<endl;
    if(y==8) cout<<"男"<<endl;
}


void Display()
{    
    
     cout<<"=============================="<<endl;   
     cout<<"1-8号学生成绩资料查询"<<endl;
     cout<<"\t"<<"学号:"<<ID<<endl;
     cout<<"\t"<<"姓名:"<<NAME<<endl;
     cout<<"\t"<<"性别:"<<SEX<<endl;
     cout<<"\t"<<"语文:"<<a<<"\t"<<"网络技术:"<<b<<endl;
     cout<<"\t"<<"C++:"<<c<<"\t"<<"数据库:"<<d<<endl;
     cout<<"\t"<<"photoshop: "<<e<<"\t"<<"总计: "<<sum<<endl;
     cout<<"=============================="<<endl;
    
}
};
int main()
{
    student stu1:
    stud1.Display();
     for(int i=0;i<=7;i++)
     {cout<<"\t"<<SCORE[i]<<endl;}
     if(i>8 || i<1)
     return 0;
}




错误:
--------------------Configuration: 改 - Win32 Debug--------------------
Compiling...
改.cpp
G:\C++\复件 c1\改.cpp(78) : error C2065: 'a' : undeclared identifier
G:\C++\复件 c1\改.cpp(78) : error C2065: 'b' : undeclared identifier
G:\C++\复件 c1\改.cpp(79) : error C2065: 'c' : undeclared identifier
G:\C++\复件 c1\改.cpp(79) : error C2065: 'd' : undeclared identifier
G:\C++\复件 c1\改.cpp(80) : error C2065: 'e' : undeclared identifier
G:\C++\复件 c1\改.cpp(80) : error C2065: 'sum' : undeclared identifier
G:\C++\复件 c1\改.cpp(87) : error C2065: 'student' : undeclared identifier
G:\C++\复件 c1\改.cpp(87) : error C2146: syntax error : missing ';' before identifier 'stu1'
G:\C++\复件 c1\改.cpp(88) : error C2065: 'stud1' : undeclared identifier
G:\C++\复件 c1\改.cpp(88) : error C2228: left of '.Display' must have class/struct/union type
G:\C++\复件 c1\改.cpp(90) : error C2065: 'SCORE' : undeclared identifier
G:\C++\复件 c1\改.cpp(90) : error C2109: subscript requires array or pointer type
Error executing cl.exe.

改.obj - 12 error(s), 0 warning(s)

=====================================================================
如果行的话直接改个正确的吧.3Q了
2007-12-20 15:31
Nasa_Mitnick
Rank: 1
等 级:新手上路
威 望:1
帖 子:45
专家分:0
注 册:2007-11-26
收藏
得分:0 
你的这个程序在变量的作用域 和c++的类的概念不清楚。。自己好好看看C++类的定义吧。很简单的
2007-12-20 16:32
解放台湾!
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-12-20
收藏
得分:0 
楼上一针见血
2007-12-20 17:04
快速回复:【求助】帮忙改下错误!
数据加载中...
 
   



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

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