I am trying to figure out how to store and access an array, which is created inside a function, and needs to be accessed outside the function.
You need to dynamically create it, and then return the pointer. But that's not exactly good programming. Naked dynamic arrays being passed around are not exactly great programming in C++.
Your easiest solution is to use vectors in place of arrays. Boost also has an array wrapper. I wouldn't advise writing your own managed structure.
"*address" is a pointer to the user-defined class
Warning. To refer to the pointer itself, it's just address. *address dereferences the pointer.
Fundamentally, you do not understand pointers and their relationship to arrays. This is troublesome, as your code is fundamentally broken. As you are using C++, I urge you to immediately look into vectors and use them. I'll explain your fundamental misunderstanding as shown by the code. At your leisure, you may then read about the necessary topics in a C++ book.
A pointer is not an array. Never is. It's simply some virtual address of another variable. This means a couple things right off. When you dereference a pointer, you are trying to access the actual memory or whatever referred to by the pointer. When you say *address = matrix, you have just derefenced address. It better be pointing to a valid location. If not, potentially you'll crash the program, as that dereference accesses a bad memory location and the OS terminates your program.
What you would have to do is create a dynamic array using new, which returns a pointer you can then assign to address. You could then access each element of the array like address[0] and address[1], along the lines of
-
address[index]->setValue(matrix.getValue);
-
address[index]->setPseudoAddress( matrix.pseudoAddress);
-
Here, index is some value that indicates a position in the array. And -> is an operator which takes care of the whole (*a).b ugliness (it becomes a->b.