关于迭代器的使用问题


#include
#include
using namespace std;
template<class T>
class ClassMyVec:public vector
{
public:
    int it;
    void CreatVector(int n)
    {
        T x;
        for (int i = 0; i < n; i++)
        {
            cin >> x;
            if (this->empty())//判断容器 谁调用函数就指向谁
                this->push_back(x);
            else if (x <= this->front)
            this->insert(this->begin(), x);
            else if (x >= this->back)
                push_back(x);
            else
            {
                vector::iterator it = begin();  //迭代器
                while ((*it < x) && it != end())
                it++;
                insert(it, x);  //在it位置插入x
            }
        }
    }
    void ShowVector()  //输出向量
    {
        if (empty())
        {
            cout << "NULL" << endl;
            return;
        }

        vector::iterator int it = begin();//迭代器输出向量
        while (it != end())
        {
            cout << *it++ << ' ';
            //it++;
        }

        for (int i = 0; i < size(); i++)
        {
            cout << this->at(i) << ' ';
            cout << endl;
        }
    }
};
int main()
{
    ClassMyVec<int>v;
    v.CreatVector(10);
    v.ShowVector();
    return 0;
    system("pause");

}

上面是我的代码,
下面是我的错误:

img

img

问题主要是出在迭代器使用语句那里,it。
问一下朋友们怎么解决谢谢了。

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^