MFC里面到底可不可以用vector啊?我在StdAfx.h里面加了#include   <vector>   using   namespace   std;在类的成员变量里面用了vector类型,还有函数的参数里面也有vector类型,开始一个一个函数写的时候编译好像没问题,最后全写完就出问题了。:\vc98\include\xmemory(34) : error C2538: new : cannot specify initializer for arrays
        e:\vc98\include\xmemory(66) : see reference to function template instantiation 'void __cdecl std::_Construct(int (*)[2],const int (&)[2])' being compiled
Generating Code...
E:\FHACA\Ant.cpp(84) : warning C4786: '__ehhandler$?Layout@CAnt@@QAEXV?$vector@V?$vector@HV?$allocator@H@std@@@std@@V?$allocator@V?$vector@HV?$allocator@H@std@@@std@@@2@@std@@V?$vector@HV?$allocator@H@std@@@3@V?$vector@V?$vector@NV?$all
ocator@N@std@@@std@@V?$allocator@V?$vector@NV?$allocator@N@std@@@std@@@2@@3@@Z' : identifier was truncated to '255' characters in the debug information
不知道什么意思,是不能用vector吗?我对MFC不太熟,谁能帮帮忙

解决方案 »

  1.   

    MFC能用vector,一般不把它放在Stdafx.h下,在哪个类中用到
    就写在那个类中
    错误的好像是你构造vector是参数出现的问题。你在检查下吧
      

  2.   

    有个变量是vector<int[2]> m_radius,要作为函数void genarate(vector<int[2]> radius)参数,这个用法有没有错?
      

  3.   


    试试看:
    typedef int Data[2] DATA;
    vector<DATA> vecData;
    void func(vector<DATA>& vecDat);
      

  4.   

    有个变量是vector <int[2]> m_radius,要作为函数void genarate(vector <int[2]> radius)参数,这个用法有没有错? 
    ====================================================================================
    错了. 你看看错误 
    error C2538: new : cannot specify initializer for arrays 
    'void __cdecl std::_Construct(int (*)[2],const int (&)[2])' being compiled 
      

  5.   

    好像是MFC里面定义的vector变量没有初始化就不能直接使用,但是又不能在定义的时候vector<int> m_r(15);在使用前加上m_r.reserve(15);好像就可以了,但是二维的vector数组又不能这样,不知道应该怎么用了
      

  6.   

    肯定可以用vector,而且你包含vector的方式也没有错误,应该是具体实现哪里出错了,一点一点来。
      

  7.   

    用vector运行速度太慢,还是用静态数组算了