CString类在赋值操作期间崩溃。 [英] CString Class is crashing during the assignment operation.

查看:1051
本文介绍了CString类在赋值操作期间崩溃。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

static CStringData * __cdecl CloneData(_Inout_ CStringData * pData)

{

CStringData * pNewData = NULL;



// *********这个代码行是C String崩溃的点********* //

static CStringData* __cdecl CloneData(_Inout_ CStringData* pData)
{
CStringData* pNewData = NULL;

//*********This line of code is point where C String is Crashing*********//

IAtlStringMgr * pNewStringMgr = pData-> pStringMgr-> Clone();

IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone();

// ****************** //

//******************//

这是代码压痕的行在任务操作期间。请为当前问题提供出路。

This is the line where code is creasing during the assignment operation. kindly provide the way out for the current problem.

harendra

推荐答案

由于pNewData为NULL,因此不允许取消引用它。 试图这样做会导致不明确的行为。 最好的未定义行为是您的程序立即崩溃。

Since pNewData is NULL, you are not allowed to dereference it.  Attempting to do so causes undefined behavior.  The best possible undefined behavior is for your program to crash immediately.

也许您真的在寻找类似于
     CStringData * pNewData = new CStringData;

现在pNewData指向由分配空间中的各种构造函数构建的实际对象。

Perhaps you were really looking for something like
     CStringData *pNewData = new CStringData;
Now pNewData points to an actual object which was built by the various constructors in the allocated space.


这篇关于CString类在赋值操作期间崩溃。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆