I get what pointers do, I know how to use them (atleast in the code part), but I have no idea how to use them practically.
So, can anyone give me some examples, or reasons why i'd need to use them. Thankyou for anyone who replies. ^-^
I know like.. it points to the memory address of the variable (or class) that we point it too, and that it can be used to point to the value aswell (& and *).
Pointers :@
Started by Phoenixz, Jan 23 2010 10:27 AM
4 replies to this topic
#1
Posted 23 January 2010 - 10:27 AM
|
|
|
#2
Posted 23 January 2010 - 10:35 AM
Most importantly, you can allocate memory on the fly without using a named variable. If you have a named variable that is a pointer to a struct that contains a pointer to itself, you can then create a chain of structs with an arbitrary number of structs in the chain, all through one named variable.
Linked lists and other fundamental data structures would be almost impossible without pointers.
Linked lists and other fundamental data structures would be almost impossible without pointers.
#3
Posted 23 January 2010 - 12:33 PM
#4
Posted 25 January 2010 - 06:37 AM
Pointers have one major advantage: they make things dynamic. If you link objects together with pointers, you can create dynamic data structures like trees and linked lists, which are vital for more complex tasks. Pointers are also used in memory management. The usefulness of pointers may be unclear at first, but there are several books on the topics. Search "algorithms and data structures niklaus wirth". Wirth wrote a book that explains dynamic data structures pretty well, and it's available online. You can skip over some of the math if you don't like reading that stuff.
Life's too short to be cool. Be a nerd.
#5
Posted 29 January 2010 - 01:17 AM
pointers are just cool :).
they allow for quicker of passing information between function as well, since they will point to the memory location and that is far quicker than just making a copy of the function parameter, and since it is a pointer you can still do some actions on it as well..
there are a few good reasons for pointers..
they allow for quicker of passing information between function as well, since they will point to the memory location and that is far quicker than just making a copy of the function parameter, and since it is a pointer you can still do some actions on it as well..
there are a few good reasons for pointers..
int coffeePerDay = 10; // need to cut down!!!Codingfriends


Sign In
Create Account



Back to top









