I have a class
class Container
{
Container ()
{
...
}
...
};
And double pointer as a global variable
Container **models;
In main
I do the next
models = new Container*[10000];
After that call
models[0] = new Container();
And get exception:
access violation while trying to write address 0x00000000
What’s wrong?
Wrong is that in the class
class Container
{
public:
int **ar;
Container()
{
for(int i=0;i<10;i++)
ar[i]=0;
}
...
}
I forgot to initialize **ar
array before initializing each *ar
array. Thanks for feedback.
User contributions licensed under CC BY-SA 3.0