小编Ayu*_*mka的帖子

访问冲突读取位置0xCDCDCDD1

我正在使用Visual Studio 2013.我收到Access violation reading location 0xCDCDCDD1错误.来自维基百科的参考文献:Magic Numbers,这里,这个问题告诉我,我正在使用未初始化的指针.我认为问题在于malloc我正在使用的功能,尽管在使用之前我确实参考过CPlusPlus文档.

我的代码:

#include "SingleNode.h"
#include "SingleList.h"
#include <iostream>
SingleList::SingleList() {}
SingleList::~SingleList() {}
...
    void SingleList::addHead(int value){
    ISingleNode *temp1 = (ISingleNode *)malloc(sizeof(SingleList));
    head = NULL;
    temp1->setValue(value);
    temp1->setNext(head->getNext());
    if (!head->getNext())
    {
        head = temp1;
    }
    else
    {
        temp1->setNext(head->getNext());
        head = temp1;
    }
}

    ...
Run Code Online (Sandbox Code Playgroud)

错误在行中 temp1->setValue(value);

setValue(int value)功能包括在这里:

#include "SingleNode.h"
SingleNode::SingleNode() {}
SingleNode::~SingleNode() {}
void SingleNode::setValue(int value){
    this->value = …
Run Code Online (Sandbox Code Playgroud)

c++ heap exception visual-studio-2013

0
推荐指数
1
解决办法
2751
查看次数

标签 统计

c++ ×1

exception ×1

heap ×1

visual-studio-2013 ×1