定义堆类的异常处理类
#ifndef HEAP_EXCEPTION_H_
#define HEAP_EXCEPTION_H_
#include<stdexcept>
#include<string>
class HeapException:public std::logic_error
{
public:
HeapException(const std::string &message="")
:std::logic_error(message.c_str())
{}
};
#endif
定义堆类的存储项类
#ifndef KEY_ITEM_H_
#define KEY_ITEM_H_
#include<string>
typedef std::string KeyType;
class KeyItem
{
public:
KeyItem(){}
KeyItem(const KeyType & keyValue)
:searchKey(keyValue)
{}
KeyType getKey()const
{
return searchKey;
}
private:
KeyType searchKey;
};
#endif
heap类的头文件
#ifndef HEAP_ARRAY_H_
#define HEAP_ARRAY_H_
#include"key_item.h"
#include"heap_excep