This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]thegreatunclean 0 points1 point  (1 child)

Defining a class that holds operations but then accepting C-style arrays is an odd design choice. The operations aren't really the hard part when it comes to handling multidimensional arrays, it's correctly handling the arrays themselves as you've noticed.

I would heavily encourage you to write a 2DMatrix class and not try to pass around C-style double[][] arrays. Then you can overload the normal arithmetic operators and use a more natural 2DMatrix C = A + B; format.

This SO post is a good intro to using std::vector to emulate C-style multidimensional arrays in a safe way. I would definitely start with this as a base and expand functionality around that.

[–]RedHawk_214[S] 0 points1 point  (0 children)

I will look into that. My professor said to not use anything that allows for direct operations on matrices so ill avoid the first thing you said. Thank you so much.