Original Post
Hey, I want to allocate an array and able to delete it and resize it at any time. I also want it to be available in all functions of a class. Now it crashes. This is my current program in short: Test.cpp The program crashes when I call functionThatFillsArray(); or functionThatUsesArray();. Is it because the new array is defined in another function and the original one is deleted which is outside? And is there a way to have a general dynamic array which can be allocated, and called in differant functions? Greetings, Michael
int array_size = 3;
int *array = new int[array_size]; // the array I want to use for all functions in this cpp
void Test::deleteandnewArray()
{
delete [] array;
int *array = new int[array_size]; // the array I again want to use for all functions
}
void Test::functionThatFillsArray
{
// code filling up the array
}
void Test::functionThatUsesArray
{
// code useing the array
}