On 05/06/2018 at 22:15, xxxxxxxx wrote:
Cinema 4D Version: 14+
Language(s) : C++ ;
I want to modify a BaseArray inside a function and return it. If I try to return the same BaseArray I get an error that it is inaccessible.
For example (pseudo code) :
// Define the BaseArray
// Use the BaseArray in a function
for (Int32 i=0; i<myFloats.GetCount(); i++)
myFloats[i] = i;
return myFloats; // --------> this does not work
On 06/06/2018 at 01:33, xxxxxxxx wrote:
First of all the code, you show us is a bit weird.
If you only want to modify the BaseArray, since you pass a reference you just have to modify it without the need to return it.
Actually, the error comes from the fact that you are returning a new BaseArray. So you copy the existing BaseArray. And BasseArray doesn't have a Copy Constructor.
But if you really want to have a new BaseArray, you have to create a new BaseArray, then use newArray.CopyFrom(myFloats)
and finally, return a reference/pointer to this array.