I'm currently working my way through 'Jumping into C++', having never really sat down with C++ before. I'm currently getting to pointers and definitely need a good bit of practice there - I don't really feel comfortable using them yet as well as dynamically allocating memory.
As far as I can tell the following code runs and does what I want it to do (dynamically allocate memory for a 2d array, fill the array, print it out, and delete it, all done by passing the pointer pointer of the array to functions as arguments) but I just wanted someone with actual C++ history to take a look at it and advise me if I'm doing anything weird: https://gist.github.com/39f795b6c56e838bada2
And what the output should be:
Code:
empty array, cols: 2, rows: 3
|0 |0 |
|0 |0 |
|0 |0 |
multiplication table:
|1 |2 |
|2 |4 |
|3 |6 |
-deleting array-
empty array, cols: 5, rows: 7
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
|0 |0 |0 |0 |0 |
multiplication table:
|1 |2 |3 |4 |5 |
|2 |4 |6 |8 |10 |
|3 |6 |9 |12 |15 |
|4 |8 |12 |16 |20 |
|5 |10 |15 |20 |25 |
|6 |12 |18 |24 |30 |
|7 |14 |21 |28 |35 |
Basically any advice or suggestions are welcome.
For example, I have read before that generally you'd want to wrap your array in a class, but I haven't gotten to classes yet in the book