Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search

Modifying BaseArray inside a function

  Topic Search Topic Search
salozo View Drop Down

Joined: 2014 Mar 26
Online Status: Offline
Posts: 115
Direct Link To This Post Topic: Modifying BaseArray inside a function
    Posted: 2018 Jun 05 at 10:15pm

User Information:

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
maxon::BaseArray<Float> myFloats;

// Use the BaseArray in a function

maxon::BaseArray<Float> myFunction(&myFloats)
for (Int32 i=0; i<myFloats.GetCount(); i++)
myFloats[i] = i;
return myFloats;   // --------> this does not work

Any ideas?
Back to Top
MaximeA View Drop Down
Forum Moderator
Forum Moderator

Forum Moderator

Joined: 2018 Jan 04
Location: France - Nantes
Online Status: Offline
Posts: 119
Direct Link To This Post Posted: 2018 Jun 06 at 1:33am
Hi Salozo,

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.


Edited by MaximeA - 2018 Jun 06 at 2:27am
SDK Specialist
Back to Top

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.