C++ classes, functions, pointers

Started by
13 comments, last by maxd gaming 20 years, 8 months ago
Pointers don''t have a purpose? I can give you a really simple purpose. Imagine a struct/class/whatever. Lets imagine that this struct/class/whatever holds pixel data for an image, amongst other things. Sending this struct/class/whatever to a function, would mean COPYING the entire data to another stack, which would take quite a bit of time. Now, with a pointer to this struct/class/whatever, you would send the address of it, meaning 4 bytes and minimal overhead.
Case closed.
Advertisement
You gotta love that about gamedev. Even if the question is so basic and stupid someone steps forward and does their best to explain it in such simple terms.

InTheSackMan,Daishi, you guys are kickass.

~Wave
quote:Original post by erjo
... Now, with a pointer to this struct/class/whatever, you would send the address of it, meaning 4 bytes and minimal overhead.
Case closed.


Erjo: References

And the price we paid was the price men have always paid for achieving paradise in this life -- we went soft, we lost our edge. - "Muad'Dib: Conversations" by the Princess Irulan
erjo: References maybe?
quote:Actually, I think his totally right. Pointers don''t really serve a purpose in C++ except for increasing performance in a non algoritm based way. So the compiler should be able to care of it.


How do you expect to do any polymorphic stuff in C++ without
pointers?!!

You can do ''some'' polymorphic stuff with references - but not everything - references can not be re-assigned.



This topic is closed to new replies.

Advertisement