f:\arm\program\point\point\point.cpp(24) : error C2512: 'Time' : no appropriate default constructor

#include
using namespace std;

class Time
{
private:
    int num;
    int score;
public:
    Time(int,int);
    void ShowScore();
};
void Time::ShowScore()
{
    cout << num << '  ' <<score << endl;
}
Time::Time(int h,int m)
{
    num = h;
    score = m;
}
int main(void)
{
    Time student;
    student.ShowScore();

    return 0;
}

運行時出現error C2512: 'Time' : no appropriate default constructor available

查資料說是析構函數出錯,所有在析構函數上改了又改,最後發現時因爲在初始化對象時沒有給析構函數實參



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章