國立暨南國際大學 100 學年度第二學期小考試卷                   (考試時間: 14:10-14:20)
科目名稱:資訊系統 與網路導論 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2012.5.9
  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).
    // typedef
    #include <iostream>
    #include <vector>
    #include <list>

    using std::cout;
    using std::endl;
    using std::vector;
    using std::list;

    typedef list<int>::iterator IT;

    class CMyList: public list<int>
    {
    public:
    CMyList(IT i1, IT i2)
    {
    for (IT iter = i1; iter != i2; iter++)
    push_back(*iter);
    }

    void Print()
    {
    for (IT iter = begin(); iter != end(); iter++)
    cout << *iter << ' ';
    cout << endl;
    }
    };

    int main()
    {
    int phone[] = { 0, 4, 9, 2, 9, 1, 0, 9, 6, 0 };
    vector<int> number(phone, phone+sizeof(phone)/sizeof(phone[0]) );
    list<int> data(number.begin() + 2, number.end());
    CMyList data2(++data.begin(), data.end());
    data2.Print();
    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).
    // Size of a map container
    #include <iostream>
    #include <map>
    #include <string>

    using std::cout;
    using std::endl;
    using std::string;
    using std::map;

    int main()
    {
    map<string, int> score;
    score["Alice"] = 100;

    cout << score["Bob"] << endl;
    cout << score.size() << endl;
    return 0;
    }