I've a class and there is an array set as private. How do I make the get_array()
function? I mean, how do I return that array knowing that I will have to return a pointer of arr[0] as we know , but isn't this breaking the private rule? Is there another way of returning this array?
I actually thought of having array2 in the main, then edit that array using the class function. I think it will be a plan B if the above doesn't work.
I would use std::vectors instead of arrays in C++. You can return them just like a primitive (vector<whatever> getter(){ return foo;}
), and they tend to be easier to deal with.