Well for starters, your inFile isn't an array. And you are deleting improperly.
You are using singular new, which creates
one InFile object.
You are then using array delete (
delete[]
) which is wrong. You must only use array delete with array new... and you are not using array new.
If you don't need an array here, the easiest way to do this would be to simply not use pointers. Don't use pointers unless you have to -- they just complicate things:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class Decompress
{
private:
InFile inFile; // <- not a pointer
OutFile outFile; // <- not a pointer
public:
Decompress(char* inName, unsigned char inSize, char * outName, unsigned char outSize)
: inFile(inName, inSize) // construct the objects in your initializer list
, outFile(outName, outSize)
{
// no need to new anything
}
~Decompress()
{
// no need to delete anything
}
//...
|
Secondly, your test function is insane. Isn't the name null terminated? Why don't you just do this?
|
cout << inFile.getName();
|
Why print each character individually?
Other than that I don't see anything wrong with this class.
The mismatching new->delete[] issue might have been what's causing your problem.