Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Gammastrahler

Pointers or the real data?

This topic is 6102 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, my knowledge of C++ is code optimization, that is, when it is better to pass a pointer instead of the actual data. for example, i have a CVector3D class, and a CArray class, which stores the CVector3D´s as pointers. each of these items describe one vertex in my game engine. The same is done to normals, triangles, faces, meshes and so on, they are all stored in such pointer arrays. but i sometimes see code where it is usual to pass classes or structs directly. what is better? the good thing about pointers is that if i access one through a pointer variable, i can change it´s values and don´t need to reassign it to the array. but what´s about speed? greetings gammastrahler

Share this post


Link to post
Share on other sites
Advertisement
passing by reference is goinu be faster with adts, like arrays.

passing adt by value = create tempory adt and copy to it - a costly function.

when you pass by reference, there isnt any copying of data members.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!