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);
}