Ok so I wrote a program for my Algorithms class and Im a bit rusty on my c++
Basically it has a main .cpp file which calls all teh functions from a different file sorts.cpp (program runs mergesort, heapsort, quicksort and insertionsort) using dynamic arrays which are declared globally in the sorts.cpp file and they are initalized in a function, now if I dont call delete[] arrayname I get a CrtMemory() or something like that error if I input a large array size so I believe thats a memory leak or my freestore is being used up. Ok so my question is where do I need to call delete in order for it to work correctly, Ive tried making a function in sorts.cpp and calling it from my main to dlete the arrays but I get a damage at normal block .... at some mem address. Can someone help me out???? I would like to have it work as is, but if thats not an option would it work better beeing a class or struct and creating an overloaded destructor?
Basically it has a main .cpp file which calls all teh functions from a different file sorts.cpp (program runs mergesort, heapsort, quicksort and insertionsort) using dynamic arrays which are declared globally in the sorts.cpp file and they are initalized in a function, now if I dont call delete[] arrayname I get a CrtMemory() or something like that error if I input a large array size so I believe thats a memory leak or my freestore is being used up. Ok so my question is where do I need to call delete in order for it to work correctly, Ive tried making a function in sorts.cpp and calling it from my main to dlete the arrays but I get a damage at normal block .... at some mem address. Can someone help me out???? I would like to have it work as is, but if thats not an option would it work better beeing a class or struct and creating an overloaded destructor?