I would like to read vector file data using a function. There exist 2 pointers which point to the arrays test1 and test2 allocated and filled in the function. When calling the function ReadIn I do not know what will be the final size of these arrays. That's why I prefer to allocate the memory inside ReadIn. Furthermore they could become very large why I prefer pointers/references, too.
A deallocation of the arrays should be possible in main.
What's the best way to handle this problem??
Probably you already have noticed that C++ is a new topic for me...
The problem is that you don't pass that int*'s by reference, but by value. Because of that, in ReadIn(), changes are only made to a and b, and not to the pointers from main(). Change your function declaration + definition to: