| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 490 人关注过本帖
标题:错的稀里糊涂东倒西歪
取消只看楼主 加入收藏
maiiho
Rank: 1
等 级:新手上路
帖 子:94
专家分:7
注 册:2008-7-17
结帖率:50%
收藏
 问题点数:0 回复次数:0 
错的稀里糊涂东倒西歪
#include <iostream.h>
#include <string.h>
class student_info
{
protected:
    char *no; //学号
    char *name; //姓名
public:
    student_info(char *no1,char *name1); //构造函数
    ~student_info(); //虚构函数
    void setinfo(char *no1,char *name1); //设置函数
    virtual void printf() //输出函数
{
    cout<<"\n学号:"<<no<<"\n姓名:"<<name<<endl;
}
    virtual void input()
    {
        cout<<"请输入学号:"<<endl;
        cin>>no;
        cout<<"请输入名字:"<<endl;
        cin>>name;
    }
};
void student_info::setinfo(char *no1,char *name1)
{
    no=new char[strlen(no1)+1];
    strcpy(no,no1);
    name=new char[strlen(name1)+1];
    strcpy(name,name1);
}
student_info::student_info(char *no1,char *name1)
{
    no=new char[strlen(no1)+1];
    strcpy(no,no1);
    name=new char[strlen(name1)+1];
    strcpy(name,name1);
}
student_info::~student_info()
{
    delete []no;
    delete []name;
}
class student_grade:public student_info
{
protected:
    float gokugo;
    float eigo;
    float suugaku;
    float konpyu_ta_;
    static float sum;
    static int count;
    float ave;
public:
    student_grade()[]
    student_grade(char *no1,char *name1,float gokugo1,float eigo1,float suugaku1,float konpyu_ta_1):student_info(char *no1,char *name1)
    {
        gokugo=gokugo1;
        eigo=eigo1;
        suugaku=suugaku1;
        konpyu_ta_=konpyu_ta_1;
        count++;
    }
    void setgrade(float gokugo1,float eigo1,float suugaku1,float konpyu_ta_1);
    void input();
    void printf();
};
void setgrade(float gokugo1,float eigo1,float suugaku1,float konpyu_ta_1)
{
        gokugo=gokugo1;
        eigo=eigo1;
        suugaku=suugaku1;
        konpyu_ta_=konpyu_ta_1;
}
void student_grade::input()
{
    cout<<"输入国语成绩:"<<endl;
    cin>>gokugo;
    cout<<"输入英语成绩:"<<endl;
    cin>>eigo;
    cout<<"输入数学成绩:"<<endl;
    cin>>suugaku;
    cout<<"输入计算机成绩:"<<endl;
    cin>>konpyu_ta_;
}
float student_grade::sum=0;
int student_grade::count=0;
void main()
{
    student_info p1("001","maiiho);
    p1.printf();
}

错误信息
--------------------Configuration: asd - Win32 Debug--------------------
Compiling...
asd.cpp
G:\Users\Maiiho\Desktop\asd.cpp(54) : error C2059: syntax error : ')'
G:\Users\Maiiho\Desktop\asd.cpp(54) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
G:\Users\Maiiho\Desktop\asd.cpp(69) : error C2065: 'gokugo' : undeclared identifier
G:\Users\Maiiho\Desktop\asd.cpp(69) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
G:\Users\Maiiho\Desktop\asd.cpp(70) : error C2065: 'eigo' : undeclared identifier
G:\Users\Maiiho\Desktop\asd.cpp(70) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
G:\Users\Maiiho\Desktop\asd.cpp(71) : error C2065: 'suugaku' : undeclared identifier
G:\Users\Maiiho\Desktop\asd.cpp(71) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
G:\Users\Maiiho\Desktop\asd.cpp(72) : error C2065: 'konpyu_ta_' : undeclared identifier
G:\Users\Maiiho\Desktop\asd.cpp(72) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
G:\Users\Maiiho\Desktop\asd.cpp(89) : error C2001: newline in constant
G:\Users\Maiiho\Desktop\asd.cpp(90) : error C2146: syntax error : missing ')' before identifier 'p1'
执行 cl.exe 时出错.

asd.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: 东倒西歪 稀里糊涂 
2008-10-28 22:39
快速回复:错的稀里糊涂东倒西歪
数据加载中...
 
   



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

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