1)First, I would suggest you use a little more creativity, and not name ANY variables with the same name:
Code:
BinaryInputStream(strArray *source) {
this->source = source;
How about this:
Code:
BinaryInputStream(strArray* ptr) {
this->source = ptr;
As it is, it makes it difficult just to talk about your code.
2)You only delete memory that was allocated with new.
Code:
strArray *source;
strArray src;
source = & src;
The variable source is a pointer that was not created using new, so you wouldn't delete it. This is essentially what you are doing:
Code:
#include <iostream>
using namespace std;
int main()
{
int* source;
int num = 10;
source = #
delete source;
return 0;
}
Try running that program and see what happens.
In addition, you only use "delete []" when you created an array using "new". In otherwords, if you use "new[]", then you use "delete []". If you only used "new", then you only use "delete". Here is an example:
Code:
#include <iostream>
using namespace std;
struct Apple
{
int size;
int color;
};
int main()
{
Apple* ptr1 = new Apple;
delete ptr1;
Apple* ptr2 = new Apple[10]; //used new with '[]' somewhere to the right of new
delete [] ptr2; //..then use delete with '[]'
return 0;
}