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

    BaseArray access problem [SOLVED]

    SDK Help
    0
    6
    436
    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 06/07/2014 at 22:19, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   14 
      Platform:   Windows  ;   
      Language(s) :

      ---------
      Hi
      I am creating a BaseArray: 
      c4d_misc::BaseArray<Vector> MyVectorArray

      If I try to pass it to a function, the compiler throws an error: 
      'c4d_misc::BaseArray<T>::BaseArray' : cannot access private member declared in class 'c4d_misc::BaseArray<T>'

      I can pass a GeDynamicArray to a function without problems, but I would like to use BaseArray for its speed.

      So basically, how do I pass a BaseArray to a function.

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

        On 08/07/2014 at 12:57, xxxxxxxx wrote:

        No hint on passing a BaseArray to a function?

          
        	c4d_misc::BaseArray<Vector> MyVectorArray;
        	MyVectorArray.Resize(10);
        	for (int i=0; i<10; i++) MyVectorArray[i] = Vector(0,i,0);
        	GePrint(RealToString(MyVectorArray[5].y));   			         //5  This works!!!
          
        	printVectorBaseArray(MyVectorArray);			            	//DOES NOT WORK....BaseArray is Inaccessible!!!
          
          
          
        void printVectorBaseArray(c4d_misc::BaseArray<Vector> inputVectorArray) 
        { 
               GePrint(RealToString(inputVectorArray[5].y));
        }
          
          
        
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 08/07/2014 at 13:51, xxxxxxxx wrote:

          It protects you from passing the array by value, which is what you are doing. The function call
          would require to copy the whole array. Pass it as a pointer or reference (usually preferred).

          void printVectorBaseArray(c4d_misc::BaseArray<Vector> **&** inputVectorArray)  
          { 
                 GePrint(RealToString(inputVectorArray[5].y));
          }
          

          -Niklas

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

            On 08/07/2014 at 15:18, xxxxxxxx wrote:

            It works. Thanks Niklas!

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

              On 09/07/2014 at 08:19, xxxxxxxx wrote:

              But please do not forget about  const  if the array do NOT need to be modified inside function.

                
              void printVectorBaseArray( **const** c4d_misc::BaseArray<Vector> **&** inputVectorArray)  
              { 
                     GePrint(RealToString(inputVectorArray[5].y));
              }
                
              
              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

                On 09/07/2014 at 11:18, xxxxxxxx wrote:

                That's a good tip, thanks Remo!

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