Hi, I'm following the code from http://www.cplusplus.com/doc/tutorial/dynamic/ (at the bottom under the "Operators delete and delete[]) to try and make a dynamic array but I'm trying to do it in an object oriented way for school.
I have my specification and implementation file and my main program. The problem is the program always crashes when it goes to output the array and I cant figure out why. The program works fine like in the tutorial if I have it all in main but not when I separate it. Can anyone see what I'm doing wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
//specification file
class Numbers
{
public:
void inputSize();
void inputNum();
void outputNum();
void deleteArray();
int size = 0;
int *ptr = newint[size];
private:
};
Thanks for your reply, I'm not really familiar with the virtual keyword and I haven't really started using destructors yet. I was hoping more to find the problem with the code that I wrote and try and fix that. Is there anything in my code that could be causing my program to crash?