class RLE_v1
{
struct header
{
char sig[4];
int fileSize;
unsigned char fileNameLength;
std::string fileName;
} m_Header;
RLE<char> m_Data;
public:
void CreateArchive(const std::string& source)
{
std::ifstream::pos_type size;
char* memblock;
std::ifstream file (source, std::ios::in|std::ios::binary|std::ios::ate);
if (file.is_open())
{
size = file.tellg();
memblock = new char [static_cast<unsigned int>(size)];
file.seekg (0, std::ios::beg);
file.read (memblock, size);
file.close();
//
// trying to make assignment to m_Data here.
//
delete[] memblock;
}
}
void ExtractArchive(const std::string& source);
};
我正在尝试将“memblock”char 数组中的数据复制到变量 m_Data 中,但是当我尝试这样做时,我得到了错误no match for operator "=" matches these operands
。我不知道如何使它们相等,因为m_Data
已经是 type char
。
这是具有变量 m_Data 作为 mem 的 RLE 类
template <typename T>
struct RLE
{
T* m_Data; // Memory which stores either compressed or decompressed data
int m_Size; // Number of elements of type T that data is pointing to
RLE()
: m_Data(nullptr)
, m_Size(0)
{ }
~RLE()
{
delete m_Data;
}
};