简体   繁体   English

C ++:调试断言失败,afx.inl行122

[英]C++: Debug assertion failed, afx.inl line 122

here is the description of the problem. 这是问题的描述。

I have the following class defined.. 我定义了以下类。

class classA {
public:
  CString aString;
};
extern classA theApp;

in another class function, I do this 在另一个类函数中,我这样做

theApp.aString = "test string";

then I get the runtime error debug assertion failed, afx.inl line 122; 然后我得到运行时错误调试断言失败,afx.inl第122行; please advise. 请指教。

I tried to do the allocation inside the class as well but it fails flagging the same runtime error. 我也尝试在类内部进行分配,但是它无法标记相同的运行时错误。

 class classA {
    public:
      CString aString;
      void set_string()
      {
          aString = "test string 2";
      }
    };
    extern classA theApp;

    //in another class function

    theApp.set_string();

visual c++ version: VC++ 6.0 可视C ++版本:VC ++ 6.0

afx.inl` line 122: ASSERT(m_pchData != NULL); afx.inl`第122行:ASSERT(m_pchData!= NULL); return ((CStringData*)m_pchData)-1; return((CStringData *)m_pchData)-1; } }

It seems, that your theApp variable is not initialized properly, since its members aString internal buffer is NULL , check that you are not making an assignment before its initialization. 看来,您的theApp变量未正确初始化,因为它的成员aString内部缓冲区为NULL ,请检查您是否在初始化之前未进行赋值。

Also ensure that you have the latest service pack (SP6) installed for the Visual Studio 6. 此外,还要确保已为Visual Studio 6安装了最新的Service Pack(SP6)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM