如下面程序
vector< int > a;
a.push_back(1);
a.push_back(2);
a.push_back(3);
a.push_back(4);  /* */在VC调试中运行到上面注释那行,在watch窗打入a,结果是
allocator
a.first
a.last
a.end只能看到第一个值如何才能看到所有值,谢谢

解决方案 »

  1.   

    Noway
    不过可以写一个打印所有元素的小函数。代替调试
      

  2.   

    建议你从stl的容器继承,然后实现一个tostring的成员函数,在调试的时候就可以用这个函数.
      

  3.   

    我写了一个,用了模板模板参数, vc6是不支持,在dev-cpp下测试的
    如果象要查看不同的数据类型,需要对data2str模板函数进行特化扩充,
    下面的例子只支持inttemplate <class type>
    string data2str(type value)
    {
        int i;
        100 = i;
    }template <>
    string data2str(int value)
    {
        string ret;
        char buf[100];
        memset(buf,0,100);
        itoa(value,buf,10);
        ret = buf;
        return ret;    
    }template <class dtype, template <class _t> class contain>
    class ext_contain : public contain<dtype>
    {
    public:
        typedef typename contain<dtype>::iterator iterator;
        string ToStr() {
            string ret;
            iterator lp;
            for (lp = begin(); lp != end(); lp++) {
                ret += data2str(*lp);
                ret += "  ";
            }
            return ret;
        }    
    };    void test()
    {
        int i;
        string info;
        ext_contain<int,vector> lv;
        for (i = 0; i < 100; i++) {
            lv.push_back(i);
        }
        info = lv.ToStr();
        cout << info.c_str() << endl;
        
        ext_contain<int,list> ll;
        for (i = 100; i < 150; i++) {
            ll.push_back(i);
        }    
        info = ll.ToStr();
        cout << info.c_str() << endl;
        
    }