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

Modifying BaseArray inside a function

 Post Reply Post Reply
Author
Message
salozo View Drop Down
Member
Member


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

User Information:

Cinema 4D Version:   14+ 
Platform:      
Language(s):     C++  ;   

---------

Hello,

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;
myFloats.Resize(10);

// 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: 54
Post Options Post Options   Quote MaximeA Quote  Post ReplyReply 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.

Cheers,
Maxime


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

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.109 seconds.