| Lim Boon Jye (53) | |
| thanks | |
|
Last edited on
|
|
| Disch (8349) | |||||
a = new int[limit];[limit]This is wrong. You can't create a straight 2D array dynamically in C++. The closest you can get is a pointer-to-pointer style 2D array:
But as you can see, it's ugly. And the manual cleanup is easy to forget. (forgetting cleanup = memory leak) A better solution would be to avoid doing the dynamic allocation manually... and instead use a container class like vector:
| |||||
|
Last edited on
|
|||||
| Lim Boon Jye (53) | |
| thanks | |
|
Last edited on
|
|
| Lim Boon Jye (53) | |
|
for this question i need to create a 2d dynamic array that if cin>>limit; a[limit][limit]; just want to get this concept.. | |
|
|
|
| Disch (8349) | |||
You're defining a twice:
Pick one. | |||
|
|
|||