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.
C++ classes, functions, pointers
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
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
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
Popular Topics
Advertisement