const Vec to Vec



  • On 09/06/2013 at 05:07, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:      
    Language(s) :     C++  ;

    ---------
    Hi Folks,

    I'm in need of a little c++ lesson here - how do I convert from a const Vector * to a Vector *? Example of what I've tried below:

      
    from:   
    const Vector *CVec = Vector(100,100,100);   
    to   
    Vector *NewVec;   
    NewVec = CVec; // doesn't seem to work..   
    

    Regards,

    WP.



  • On 09/06/2013 at 06:11, xxxxxxxx wrote:

    hi, I am a C++ beginner, so I have no idea if this is what you are after, but here is something I myself use:

    vector<LONG>* vLong = new vector<LONG>();
    

    Hope this helps



  • On 09/06/2013 at 06:13, xxxxxxxx wrote:

    Use a const_cast with pointers:

    Vector* NewVec = const_cast<Vector*>(CVec);
    

    Still, if you don't require CVec to be const (immutable) you should define it as such and avoid the conundrum altogether.  You could also make a new vector and copy the pointed contents from the constant to it so that the 'contents' become mutable.



  • On 09/06/2013 at 10:48, xxxxxxxx wrote:

    Thanks to Both of you. I may have finally found a part-solution to a 12+ month problem of mine!

    Cheers,

    WP.


Log in to reply