I need to return an array of class objects from a function. I understand from research that the best way to do this is with a pointer, but is this the best way given my program design, and the need to access this from multiple CPP files?
main.cpp
#include <class.h>
#include <functions.h>
int main(){
Class Object[2][]; //define second dimension here?
some_function(); //should return / create the array with filled in elements.
int var = arr[2][3]; // want to be able to do something like this in main
}
functions.cpp
void some_function(){
// assign values
arr[2][3] = 1;
}
vector<vector<int>> some_function() {...}Of course you'll need C++11 to use<int>>and not<int> >.