typedef vector<CStringArray> CStringArrayTwo;void Cselpeopledlg::LoadFile(CString nFileName,CStringArrayTwo& arrtStr)//读取文件获取最近
{
//获取文件名
CString des=_T("");
TCHAR exeFullPath[MAX_PATH]; // MAX_PATH
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
des=(LPCSTR)exeFullPath;
int n = des.ReverseFind('\\');
des = des.Left(n);
CString  nFileFullName = des+_T("\\")+nFileName;
m_LoadFileName = nFileFullName; //读文件
CString nLines = ReadFileByLine(RECENTLINES,m_LoadFileName);
m_szReadFileLineTexts = nLines;//保存读出各行的字符串到内部变量 //分割每行到数组
CStringArray arrStr;
CStringArray arrSubStr;
char str1 = _T('\n');
char str2 = _T('|');
n_slipt(m_szReadFileLineTexts,str1,arrStr);
for(int i=0;i<arrStr.GetCount();i++)
{
n_slipt(arrStr[i],str2,arrSubStr);
arrtStr.push_back(arrSubStr);
}

m_boIsLoadFile = TRUE;
}
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include\afxcoll.h(590) : error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject'

解决方案 »

  1.   

    CStringArray对象不能拷贝.
    而vector里面放的元素需要能够拷贝,所以编译错误.
      

  2.   

    谢谢楼上,弱弱的问一下CStringArray为什么不能拷贝的?
      

  3.   

    另外
    typedef vector<CString> MyCStringArray;
    typedef vector<MyCStringArray> CStringArrayTwo;
    改成这样可以吗
      

  4.   

    typedef vector<CStringArray&> CStringArrayTwo; 看看, 至于加不加const 看你的使用了。
      

  5.   

    typedef vector <CStringArray&> CStringArrayTwo;好象不行
      

  6.   

    typedef vector <CStringArray> CStringArrayTwo
      

  7.   

    不一样,报的更多
    C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(95) : error C2528: 'pointer' : pointer to reference is illegal
    1>        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(429) : see reference to class template instantiation 'std::allocator<_Ty>' being compiled
    1>        with
    1>        [
    1>            _Ty=CStringArray &
    1>        ]
    1>        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(439) : see reference to class template instantiation 'std::_Vector_val<_Ty,_Alloc>' being compiled
    1>        with
    1>        [
    1>            _Ty=CStringArray &,
    1>            _Alloc=std::allocator<CStringArray &>
    1>        ]
    1>        .\selpeopledlg.cpp(328) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
    1>        with
    1>        [
    1>            _Ty=CStringArray &
    1>        ]
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(96) : error C2529: 'reference' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(97) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(97) : error C2528: 'const_pointer' : pointer to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(98) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(98) : error C2529: 'const_reference' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(115) : error C2535: 'CStringArray &(*std::allocator<_Ty>::address(CStringArray &(&)) const)' : member function already defined or declared
    1>        with
    1>        [
    1>            _Ty=CStringArray &
    1>        ]
    1>        C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(109) : see declaration of 'std::allocator<_Ty>::address'
    1>        with
    1>        [
    1>            _Ty=CStringArray &
    1>        ]
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(153) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\xmemory(153) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(486) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(486) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(486) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(492) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(492) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(492) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(544) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(544) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(808) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(808) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(869) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(869) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(874) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(874) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(881) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(881) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1099) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1099) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1157) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1157) : error C2529: '_Val' : reference to reference is illegal
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1257) : warning C4181: qualifier applied to reference type; ignored
    1>C:\Program Files\Microsoft Visual Studio 9.0\VC\include\vector(1257) : error C2529: '_Val' : reference to reference is illegal
    1>.\selpeopledlg.cpp(328) : error C2662: 'std::vector<_Ty>::push_back' : cannot convert 'this' pointer from 'const CStringArrayTwo' to 'std::vector<_Ty> &'
    1>        with
    1>        [
    1>            _Ty=CStringArray &
    1>        ]
    1>        Conversion loses qualifiers
      

  8.   

    郁闷了,下班了, 帮忙把CStringArray的定义贴出来吧,我再看看,晕死
      

  9.   

    class CStringArray : public CObject
    { DECLARE_SERIAL(CStringArray)
    public:// Construction
    CStringArray();// Attributes
    INT_PTR GetSize() const;
    INT_PTR GetCount() const;
    BOOL IsEmpty() const;
    INT_PTR GetUpperBound() const;
    void SetSize(INT_PTR nNewSize, INT_PTR nGrowBy = -1);// Operations
    // Clean up
    void FreeExtra();
    void RemoveAll(); // Accessing elements
    const CString& GetAt(INT_PTR nIndex) const;
    void SetAt(INT_PTR nIndex, LPCTSTR newElement); void SetAt(INT_PTR nIndex, const CString& newElement); CString& ElementAt(INT_PTR nIndex); // Direct Access to the element data (may return NULL)
    const CString* GetData() const;
    CString* GetData(); // Potentially growing the array
    void SetAtGrow(INT_PTR nIndex, LPCTSTR newElement); void SetAtGrow(INT_PTR nIndex, const CString& newElement); INT_PTR Add(LPCTSTR newElement); INT_PTR Add(const CString& newElement); INT_PTR Append(const CStringArray& src);
    void Copy(const CStringArray& src); // overloaded operator helpers
    const CString& operator[](INT_PTR nIndex) const;
    CString& operator[](INT_PTR nIndex); // Operations that move elements around
    void InsertAt(INT_PTR nIndex, LPCTSTR newElement, INT_PTR nCount = 1); void InsertAt(INT_PTR nIndex, const CString& newElement, INT_PTR nCount = 1); void RemoveAt(INT_PTR nIndex, INT_PTR nCount = 1);
    void InsertAt(INT_PTR nStartIndex, const CStringArray* pNewArray);// Implementation
    protected:
    CString* m_pData;   // the actual array of data
    INT_PTR m_nSize;     // # of elements (upperBound - 1)
    INT_PTR m_nMaxSize;  // max allocated
    INT_PTR m_nGrowBy;   // grow amount void InsertEmpty(INT_PTR nIndex, INT_PTR nCount);
    public:
    ~CStringArray(); void Serialize(CArchive&);
    #ifdef _DEBUG
    void Dump(CDumpContext&) const;
    void AssertValid() const;
    #endifprotected:
    // local typedefs for class templates
    typedef CString BASE_TYPE;
    typedef LPCTSTR BASE_ARG_TYPE;
    };
      

  10.   

    @_@!原来spring203大哥没看到之前的回复
      

  11.   

    因为基类CObject禁止对象拷贝,导致所有CObject派生累禁止拷贝 // Disable the copy constructor and assignment by default so you will get
    //   compiler errors instead of unexpected behaviour if you pass objects
    //   by value or assign objects.
    protected:
    CObject();
    private:
    CObject(const CObject& objectSrc);              // no implementation
    void operator=(const CObject& objectSrc);       // no implementation
      

  12.   

    谢谢各位,我用
    typedef vector <CString> MyCStringArray;
    typedef vector <MyCStringArray> CStringArrayTwo; 
    编译没错,希望不会出其他问题,结贴