[問題] c++出現的錯誤

看板C_and_CPP作者 (kevin)時間14年前 (2011/04/14 03:42), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
開發平台(Platform):C++ 問題(Question):我有除錯有過,但是計算時就出了問題, 不會問我該輸入幾分,請問我該修正哪個部份,謝謝 程式碼(Code): using namespace std; class student { public: int average_score(){ return (eng + math + c)/3; } void setID(int i){ id = i; } void setName(char* str){ strcpy(name,str); } void engScore(int score){ eng = score; } void mathScore(int score){ math = score; } void cppScore(int score){ c = score; } private: char name[10]; int id; int eng; int math; int c; }; int main(int argc, char *argv[]) { char* str1; int id; int score; student allan_name; cout<<"請輸入學生姓名:"; cin>>str1; allan_name.setName(str1); cout<<"請輸入學生學號:"; cin>>id; allan_name.setID(id); cout<<"請輸入英文成績:"; cin>>score; allan_name.engScore(score); cout<<"請輸入數學成績:"; cin>>score; allan_name.mathScore(score); cout<<"請輸入C++成績:"; cin>>score; allan_name.cppScore(score); cout<<"平均分數為:" << allan_name.average_score(); system("PAUSE"); return EXIT_SUCCESS; } 補充說明(Supplement):無 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.165.253

04/14 04:04, , 1F
char str1[256];
04/14 04:04, 1F

04/14 04:38, , 2F
感謝purpose大幫忙 問題順利解決了
04/14 04:38, 2F

04/14 11:27, , 3F
請修改為較符合內文的標題, 譬如出現的錯誤
04/14 11:27, 3F
※ 編輯: kevin888 來自: 118.166.170.234 (04/14 15:53)
文章代碼(AID): #1DfVokiy (C_and_CPP)