國立暨南國際大學 100 學年度第二學期小考試卷                   (考試時間: 14:10-14:20)
科目名稱:資訊系統 與網路導論 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2012.3.7
  1. (10%) Determine whether the following code has syntax errors or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    // Define a class
    #include <iostream>
    using std::cout;
    using std::endl;

    class CBox                     // Class definition at global scope
    {
        double m_Length;           // Length of a box in inches
        double m_Width;            // Width of a box in inches
        double m_Height;           // Height of a box in inches
    };

    int main()
    {
      CBox box1;                   // Declare box1 of type CBox

      box1.m_Height = 18.0;        // Define the values
      box1.m_Length = 78.0;        // of the members of
      box1.m_Width = 24.0;         // the object box1 

      cout << "Volume of box1 = "
           <<  box1.m_Height*box1.m_Length*box1.m_Width
           << endl;
      return 0;
    }


  2. (10%) Determine whether the following code has syntax errors or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    // Define a class
    #include <iostream>
    using std::cout;
    using std::endl;

    class CBox                     // Class definition at global scope
    {
        double m_Length;           // Length of a box in inches
        double m_Width;            // Width of a box in inches
        double m_Height;           // Height of a box in inches
    public:
        CBox(double lv, double bv = 1.0, double hv=1.0)
        {                         
    // Default value of parameters
                m_Length = lv; m_Width = bv; m_Height = hv;
        }
        double Volume()
        { return m_Length * m_Width * m_Height; }
    };

    int main()
    {
      CBox box1(18.0, 18.0);      // Declare box1 of type CBox

      cout << "Volume of box1 = " <<  box1.Volume()
           << endl;
      return 0;
    }