Advertisement Jump to content


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


Pointers or the real data?

This topic is 6200 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
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, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!