I'm trying to dynamically create an array of objects, then have them delete later on but for some reason i'm getting an error with the delete line. I'm still confused with the whole dynamic object thing, but hopefully this will help me get the hang of it. Here is what I did let me know where I am going wrong...
Inside the constructor of one file I call anther class and create it dynamically. (inside the constructor)
Score * list = new Score[10];
I'm not having any errors with that but when I try to delete the same thing using this code. (Inside the deconstructor)
delete [] list;
I get an error saying that
15: error: `list' undeclared (first use this function)
Here is my code for both the constructor and deconstructor...
Storage::Storage(int dis)
{
Score * list = new Score[10];
}
Storage::~Storage()
{
delete [] list;
}
Any idea?