• Breaking News

    Self managed object, bad practice in C++? Hi everybody, Let's take the example of one keyframe class and one track class. The track contains an array of keyframe, so the track own the keyframe. Is it a bad practice to get the pointer of the track, the owner, in keyframe and remove from the track in the destructor? Basically doing "delete keyframe", you don't have to do remove from the track before the delete. But then the issue of this design is if multiple class share the element, it's not safe because it will remove only on the track but not the other place. Another issue is if you create the keyframe on the stack and add this keyframe in the track: { Keyframe keyframe; m_Track.Add(keyframe); } At the end of this scope, the keyframe will be removed from the m_track, it's not safe on this case too. What do you think about all that? https://ift.tt/eA8V8J

    Hi everybody, Let's take the example of one keyframe class and one track class. The track contains an array of keyframe, so the track own the keyframe. Is it a bad practice to get the pointer of the track, the owner, in keyframe and remove from the track in the destructor? Basically doing "delete keyframe", you don't have to do remove from the track before the delete. But then the issue of this design is if multiple class share the element, it's not safe because it will remove only on the track but not the other place. Another issue is if you create the keyframe on the stack and add this keyframe in the track: { Keyframe keyframe; m_Track.Add(keyframe); } At the end of this scope, the keyframe will be removed from the m_track, it's not safe on this case too. What do you think about all that?

    from GameDev.net http://bit.ly/2EDQs9h

    ليست هناك تعليقات

    Post Top Ad

    ad728

    Post Bottom Ad

    ad728