+ 3
What is the useful of pointers and why it's existing only on c++??
why we study pointers ??
4 Respostas
+ 9
Let's say I have a copy of a dictionary in memory.
Now I ask a function to find a word in that dictionary.
Do I :
- Send the entire dictionary to the function (which it has to finish retrieving before it can even start looking)
- Tell it where the dictionary is stored, so it can go look for itself?
Answer:
I point at where I've stored the dictionary.
It doesn't need its own copy.
You study pointers because there are various ways to point at things you don't want to copy.
+ 11
There are pointers in Pascal too...
But basically it's more efficient to pass pointers to objects that have a lot of data in them, in a function, because only the memory address is copied, not the entire data contained in them.
+ 5
its exists in C too.
Pointer allow to works with references instead of copy objects.
+ 5
Pointers exist in assembler in some way.
But Object Oriented Programming is a modern aproach, and more usefull and robust for many many cases.
Use pointers only if:
1) you are a very very expert programmer in c language
2) your application REALLY needs to be fast