(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;
}