| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 998 人关注过本帖
标题:C++类涵数调用``出错`?
取消只看楼主 加入收藏
lovely06123
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-2
收藏
 问题点数:0 回复次数:2 
C++类涵数调用``出错`?
#include <iostream>
#include <string>
using namespace std;
class Student
{
private:
    int number;
    float score1,score2,score3;
    char *name;
public:
    Student();
    void get(int ,char *,float ,float ,float);
    float aver();
    void show();
    ~Student();
};

void Student::get(int numbers,char *names,float score1s,float score2s,float score3s)
{
    number=numbers;
    name=names;
    score1=score1s;
    score2=score2s;
    score3=score3s;
}

float Student::aver()
{
    return ((score1+score2+score3)/3);
}
void Student::show()
{
    cout<<"学号:"<<number<<"姓名:"<<name<<"语文:"<<score1<<"数学:"<<score2
        <<"英语:"<<score3<<"平均分:"<<aver()<<endl;
}
void main()
{
    int i,j;
    Student s[3];
    Student temp;
    s[0].get(1,"张三",90,88,89);
    s[1].get(2,"李四",99,90,95);
    s[2].get(3,"王五",78,80,69);
    for(i=0;i<3;i++)
        for(j=0;j<2;j++)
            if(s[j].aver()<s[j+1].aver())
            {temp=s[j];s[j]=s[j+1];s[j+1]=temp;}
    cout<<"按平均分从高到低排列"<<endl;
    s[0].show();
    s[1].show();
    s[2].show();
}
执行的时候出错`编译不出错``
Linking...
class.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::Student(void)" (??0Student@@QAE@XZ)
class.obj : error LNK2001: unresolved external symbol "public: __thiscall Student::~Student(void)" (??1Student@@QAE@XZ)
Debug/class.exe : fatal error LNK1120: 2 unresolved externals
执行 link.exe 时出错.

class.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: 编译 
2008-11-02 21:04
lovely06123
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-2
收藏
得分:0 
为什么没人帮我解决吖?~
2008-11-02 21:32
lovely06123
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2008-11-2
收藏
得分:0 
谢谢``
2008-11-02 23:10
快速回复:C++类涵数调用``出错`?
数据加载中...
 
   



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

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