English 中文(简体)
_CrtisValidHeapPointer(用户数据)和 _Block_TYPE_IS_VALID(Phead->nBlockuse)[复制]
原标题:_CrtIsValidHeapPointer(pUserdata) AND _BLOCK_TYPE_IS_VALID(pHead->nBlockUse) [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
What is The Rule of Three?

我刚刚“完成”了AVL树的安装,然后去测试一下以前用普通的二进制搜索树做什么工作。但现在我得到了这些断言错误,当BsTree构建器被称作时。

_BLOCK_TYPE_IS_VALID(pHead->nBlockUse) is first and if I continue windows spits the next one out. _CrtIsValidHeapPointer(pUserdata)

TYPE在类型.h中被定义为信号* 我计划修改它,以便使用模板或什么的用于多形态执行,但对于初始设置来说这似乎很简单。

主执行 :

#include<string>
#include<iostream>
#include<fstream>
#include"binSearchTree.h"
;
using namespace std;

int main(){

string word;
int i = 0;
ifstream book ("AV1611Bible.txt");

if(book.is_open()){

    book >> word;

    bsTree* tree = new bsTree(new Signal(word));

    while( book.good()){
        book >> word;
        tree->addValue(new Signal(word));
        //cout << word;
        cout << i++ << "
";
    }
    book.close();
}


return 0;
}

bsTree 构造器:

#include"binSearchTree.h"

;
using namespace std;

bsTree::bsTree(){

root = new Node();
size = 0;
}

bsTree::bsTree(TYPE v){
root = new Node(v);
size = 0;
}

bsTree::~bsTree(){
delete root;
}

信号构造器 :

#include"signal.h"


using namespace std;


Signal::Signal(){
signal = "";
count = 0;
prob = 0;
}

Signal::Signal(string s){
Signal(s,0);
}

Signal::Signal(string s, double p){
signal = s;
count = 0;
prob = p;
}

Signal::Signal(string s, int n, double p){
signal = s;
count = n;
prob = p;
 }

Signal::~Signal(){
delete(&signal);
delete(&count);
delete(&prob);
}
问题回答

上面显示的代码有 < 坚固 > 未定义的行为 < / 强强 >, 原因是, 例如 < code> dedelete 某事没有通过 < code> new 分配, 然后 anything 可以发生, 包括您看到的任何行为( 您忘记描述) 。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?