注册 登录
编程论坛 C++教室

大家帮我解决一下

ememe 发布于 2014-03-19 23:03, 337 次点击
#include<iostream>
#include<iomanip>
using namespace std;
class score{
public:
    score();
    ~score();
    void inscore();
    void showscore();
private:
    double  math, english, programming, ave;
    char num[10];
};
void score::inscore(){
    cout << "num:";
    cin >> num;
    cout << "Input math,english,programming score:";
    cin >> math >> english >> programming;
    ave = (math + english + programming) / 3;
}
void score::showscore(){
    cout << num << setw(6) << math << setw(5)
 << english << setw(5) << programming << setw(5) << ave << "\n";
}



int main(){
    score a[10];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        a[i].inscore();
    cout << "num" << setw(6) << "math" << setw(5) << "english"
        << "programming" << setw(5) << "ave";
    for (int i = 0; i < n; i++)
        a[i].showscore();
}


错误    1    error LNK2019: 无法解析的外部符号 "public: __thiscall score::score(void)" (??0score@@QAE@XZ),该符号在函数 _main 中被引用    C:\Users\pengcheng\Documents\Visual Studio 2013\Projects\practice\practice\源.obj    practice
错误    2    error LNK2019: 无法解析的外部符号 "public: __thiscall score::~score(void)" (??1score@@QAE@XZ),该符号在函数 _main 中被引用    C:\Users\pengcheng\Documents\Visual Studio 2013\Projects\practice\practice\源.obj    practice

错误    3    error LNK1120: 2 个无法解析的外部命令    C:\Users\pengcheng\Documents\Visual Studio 2013\Projects\practice\Debug\practice.exe    1    1    practice
3 回复
#2
ememe2014-03-19 23:58
我知道了   只是     score();
                    ~score();
改为               //score();
                   //~score();
#3
fl89622014-03-20 06:57
#4
hubinyes2014-03-20 09:48
。。。。。构造函数,析构函数只有申明,,没有实现体。。
1