none
VC++錯誤 RRS feed

  • 問題

  • 我一直找不到,而且都照著書上Key,還是有錯,請各位大大幫忙,謝謝

     

    #include <iostream.h>
    #include <string.h>

    class Math
    {
    private:
     int Math_Score;
    public:
     Math_make(int a)
     {
      Math_Score = a;
     }
     Math_take()
     {
      return Math_Score;
     }
    };

    class Chinese
    {
    private:
     int Chinese_Score;
    public:
     Chinese_make(int b)
     {
      Chinese_Score = b;
     }
     Chinese_take()
     {
      return Chinese_Score;
     }
    };

     

    class History
    {
    private:
     int History_Score;
    public:
     History_make(int c)
     {
      History_Score = c;
     }
     History_take()
     {
      return History_Score;
     }
    };

     

    class Student: public Math, protected Chinese, private History
    {
    private:
     int Student_Number;
    protected:
     char Student_Name[20];
    public:
     Student(int d, char *N)
     {
      Student(int d,char *N)
      {
       Student_Number = d;
       strcpy (Student_Name, N);
      }

      Student_C_make(int e)
      {
       Chinese_make (e);
      }
      Student_H_make(int f)
      {
       History_make(f);
      }
      void Student_Show()
      {
       cout << endl;
       cout << " Number : " << Student_Number << endl;
       cout << " Name : " << Student_Name << endl;
       cout << " Math Score : " << Math_take << endl;
       cout << " Chinese Score : " << Chinese_take << endl;
       cout << " History Score : " << History_take << endl;
       cout << " Total Score : " << Math_take()+Chinese_take()+History_take() << endl;
      }
    };

     

    int main()
    {
     Student object1 (31232, "Alex");
      object1.Math_make(65);
      object1.Student_C_make(78);
      object1.Student_H_make(34);
      object Student_Show();
      return 0;
    }
    ------------------------------------------------------------------------------------------------

    CH10_02\CH10_02.CPP(12) : warning C4183: 'Math_make': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(16) : warning C4183: 'Math_take': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(27) : warning C4183: 'Chinese_make': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(31) : warning C4183: 'Chinese_take': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(42) : warning C4183: 'History_make': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(46) : warning C4183: 'History_take': member function definition looks like a ctor, but name does not match enclosing class
    CH10_02\CH10_02.CPP(93) : fatal error C1004: unexpected end of file found
    Error executing cl.exe.

    CH10_02.exe - 1 error(s), 6 warning(s)


    2008年11月10日 上午 06:57

解答

  • 妳的 第 93 行  內容是啥 ?

    請列出 CH10_02.CPP  完整內容

     

    ========================

     

    Fatal Error C1004

    Error Message

    unexpected end of file found

    The compiler reached the end of a source file without resolving a construct. The code may be missing one of the following elements:

    • A closing brace

    • A closing parenthesis

    • A closing comment marker (*/)

    • A semicolon

    To resolve this error, check for the following:

    • The default disk drive has insufficient space for temporary files, which require about twice as much space as the source file.

    • An #if directive that evaluates to false lacks a closing #endif directive.

    • A source file does not end with a carriage return and line feed.

     

    2008年11月10日 上午 07:20
  • HI,

     

    意思是以下這個方法長的像Constructor,但是宣告的不對:

     

    Math_make(int a)
     {
      Math_Score = a;
     }

     

    如果是constructor, 應該宣告成:

    Math(int a)
     {
      Math_Score = a;
     }

    而以下這個函數, 少宣告傳回值:


     Math_take()
     {
      return Math_Score;
     }

    應該改成:

     

    int Math_take()
     {
      return Math_Score;
     }

    tihs
    2008年11月11日 上午 01:12

所有回覆

  • HI,

     

    請建一個新的專案, 在專案的時候請不要勾選[先行編譯標頭檔]選項, 然後再把寫好的程式檔案加入到新的專案中建置

     

    tihs 

    2008年11月10日 上午 07:15
  • 妳的 第 93 行  內容是啥 ?

    請列出 CH10_02.CPP  完整內容

     

    ========================

     

    Fatal Error C1004

    Error Message

    unexpected end of file found

    The compiler reached the end of a source file without resolving a construct. The code may be missing one of the following elements:

    • A closing brace

    • A closing parenthesis

    • A closing comment marker (*/)

    • A semicolon

    To resolve this error, check for the following:

    • The default disk drive has insufficient space for temporary files, which require about twice as much space as the source file.

    • An #if directive that evaluates to false lacks a closing #endif directive.

    • A source file does not end with a carriage return and line feed.

     

    2008年11月10日 上午 07:20
  • HI,

     

    意思是以下這個方法長的像Constructor,但是宣告的不對:

     

    Math_make(int a)
     {
      Math_Score = a;
     }

     

    如果是constructor, 應該宣告成:

    Math(int a)
     {
      Math_Score = a;
     }

    而以下這個函數, 少宣告傳回值:


     Math_take()
     {
      return Math_Score;
     }

    應該改成:

     

    int Math_take()
     {
      return Math_Score;
     }

    tihs
    2008年11月11日 上午 01:12