Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Modifying BaseArray inside a function

    SDK Help
    0
    2
    791
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      On 05/06/2018 at 22:15, xxxxxxxx wrote:

      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?

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 06/06/2018 at 01:33, xxxxxxxx wrote:

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post