iCAx开思网

标题: 问个NX OPEN for C++二次开发中Vector的问题: [打印本页]

作者: universewave    时间: 2007-7-3 10:36
标题: 问个NX OPEN for C++二次开发中Vector的问题:
先看看代码:
    NXOpen::Features::FeatureCollection* f_collection = thePart->Features();
    for (NXOpen::Features::FeatureCollection::iterator it=f_collection->begin();it != f_collection->end();it++)
    {
        NXOpen::Features::Feature* f11= (NXOpen::Features::Feature* ) *it;
        std::vector<NXOpen::Features::Feature*> f_v;
        f_v=f11->GetChildren();
        if (f_v.size() > 0)
        {
            for (std::vector<NXOpen::Features::Feature*>::iterator it_sub=f_v.begin();
                it_sub!=f_v.end();it_sub++)
            {
                NXOpen::Features::Feature* f22= (NXOpen::Features::Feature* ) *it;
            }

        }
    }
我的目的是想把getChildren()函数所返回的vector取出来,存在另一个声明的名为f_v的vector中。第一个for循环执行的没有大问题,为什么在赋值时以及使用vector的size等函数时就出错?提示说是Access Violation?
其中,getChildren的函数说明如下:

std::vector<NXOpen::Features::Feature *> NXOpen::Features::Feature::GetChildren  (    )   

   Returns the immediate child features.

问题是现在运行到    f_v=f11->GetChildren();
这一句时,就报错了,在Log里看到说是Access Violation
++++ Fatal system exception: c0000005 Access Violation
[ 1] 148817FD xutility\std::_Container_base::_Orphan_all Line 197 +0x3d    (MSVCP80D)
[ 2] 14418F87 vector\std::vector<NXOpen::Features::Feature *,std::allocator<NXOpen::Features::Feature *> >::_Tidy Line 1092 +0x37 (Demo2)
[ 3] 14417921 vector\std::vector<NXOpen::Features::Feature *,std::allocator<NXOpen::Features::Feature *> >::~vector<NXOpen::Features::Feature *,std::allocator<NXOpen::Features::Feature *> > Line 547 +0x51

哪位大侠看看是啥问题啊? 急!




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3