| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with arrays
Here is what I want to do
I making a class and in each class there is an array. Each class is going to has the array be a different size so what I tried to do is this int matrix = new array(); //constructor matrices(int m, int n) { matrix[m][n] } what i realized later down the road is that there is no new array and that when saying matrix[m][n] i'm refering to a value in the array. So how would I create an array in a class where it is a different size in different objects of the class |
|
#2
|
|||
|
|||
|
You need to declare a pointer to the array in the class, and then use dynamic allocation to give each class its own aray. Search Google or this forum for the process of dynamically allocating a two-dimensional array (it's trickier than you'd think).
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Help with arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|