Hi,
I have a basic doubt.
Is int a class?
If we say, int x = new int(10);
then will it call a constructor of int?
If yes, then it means that when we do something like this,
int* x = new int[5];
_______
_______
delete x;
then it should be a memory leak.
And the correct way should be
delete[] x;
But that is not required, and we continue with delete x;
how?
Or, am I wrong somewhere?
Please clearify.
Thanks.
I have a basic doubt.
Is int a class?
If we say, int x = new int(10);
then will it call a constructor of int?
If yes, then it means that when we do something like this,
int* x = new int[5];
_______
_______
delete x;
then it should be a memory leak.
And the correct way should be
delete[] x;
But that is not required, and we continue with delete x;
how?
Or, am I wrong somewhere?
Please clearify.
Thanks.
Comment