Code:
#ifndef _SYMBOL_
#define _SYMBOL_
#include <assert.h>
class Tree;
class Symbol {
friend class Tree;
private:
char Character;
Symbol *Parent, *LeftChild, *RightChild;
bool Mark;
float Probability;
char CodeBit[16];
int Depth;
public:
Symbol();
Symbol(char,float);
~Symbol();
};
//==========================================
class Tree {
public:
Tree();
~Tree();
void insertSymbol(char, float);
int showLength();
void displayTree();
int findLow();
int markSymbol();
void moveSymbols(Tree*);
displaySymbol();
void printTree(Symbol*);
void printTree(void);
void assignBits();
void assignBits(Symbol*, char*);
void writeTable(ofstream*);
void writeTable(ofstream*,Symbol*);
protected:
Symbol *Root, *PtrCurrent;
int Count;
int Depth;
Symbol* removeSymbol();
int BranchCounter;
void insertSymbol(Symbol*,Symbol*);
void insertSymbol(Symbol*);
};
#include "Symbol.cpp"
#endif