// compression.h: interface for the compression class.
//
//////////////////////////////////////////////////////////////////////#include <cmath>
#include <string>
#include <fstream>
using namespace std;#if !defined(AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_)
#define AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000struct HTNode
{
char data;
int weight; //权值
int parent;
int lchild;
int rchild;
};typedef char* HCode;class compression
{
public:
compression();
virtual ~compression();//这行的~是什么意思?
bool Decompression(string fileadd2);
bool Compression(string fileadd);
bool DecompressionFile(string fileadd2,string fileadd3);
bool ConvertFile(HCode hcd[],string fileadd,string fileadd2);
unsigned char ConvertBinary(char *tmp);
void HCCreat(HTNode ht[],HCode hcd[],int n);
void HTCreat(HTNode ht[],int n);
bool InitFromFile(string fileadd);
void Dec2Bin(int num,int bin[8]);
int clean();
};#endif // !defined(AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_)
//
//////////////////////////////////////////////////////////////////////#include <cmath>
#include <string>
#include <fstream>
using namespace std;#if !defined(AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_)
#define AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000struct HTNode
{
char data;
int weight; //权值
int parent;
int lchild;
int rchild;
};typedef char* HCode;class compression
{
public:
compression();
virtual ~compression();//这行的~是什么意思?
bool Decompression(string fileadd2);
bool Compression(string fileadd);
bool DecompressionFile(string fileadd2,string fileadd3);
bool ConvertFile(HCode hcd[],string fileadd,string fileadd2);
unsigned char ConvertBinary(char *tmp);
void HCCreat(HTNode ht[],HCode hcd[],int n);
void HTCreat(HTNode ht[],int n);
bool InitFromFile(string fileadd);
void Dec2Bin(int num,int bin[8]);
int clean();
};#endif // !defined(AFX_COMPRESSION_H__48CBE69A_6648_49A0_A67C_6777B2A3767C__INCLUDED_)
既然有分,就不要放过!
那行叫作“析构函数”,前面加个“virtual”,意思是说这个函数可以是多态的,方便子类继承。
析构函数当类被“消灭”的时候都会调用一次。一般用作对类中的资源作释放处理。
看来我的答案最标准了,这5分是我的了!!!!!!!!