What are the advantages of pointers?
Hello friend,
I am beginner to the C programming. The 'Pointers' concept of C programming seem quit tough to understand. I am not able to understand the what are the advantage of using pointers in any program. Is it any special use of pointers?. If you know any advantage of using 'Pointer', then please let me know that. I will greatly appreciate you any help.
Re: What are the advantages of pointers?
The basic advantages of using pointer is that, it enables the use of dynamic memory allocation. A pointer is a variable containing the address of another variable of a type. The concept of pointer is often afraid because this is a technical programming very powerful for defining dynamic structures, that is to say that evolves over time (as opposed to tables such which are static data structures whose size is fixed to the definition.
Re: What are the advantages of pointers?
Different types of smart pointers can implement various strategies within the same program. In standard C++ has no mechanism for garbage collector (garbage collector), which a prior that could make it more complex to use that language to have. But in fact, with smart pointers, it has a different mechanism to solve the same problem of resource management. With the pointer the resource management task becomes relatively transparent.
Re: What are the advantages of pointers?
Advantages of using pointers:
- Pointer can handle simple data that can be important (instead of passing a function to a very large (in size))
- The tables can store a fixed number of elements of the same type. By storing pointers in boxes in a table, it will be possible to store elements of different sizes, and even add elements Table in use (the concept of dynamic array is very closely linked to the pointer)
Re: What are the advantages of pointers?
As in C, the C + + allows to use pointers to manipulate data, but it also introduces the concept of reference handy to allow editing of data passed in a function. A pointer is a variable that must be defined by specifying the type of variable pointed. With the symbol '*' the compiler knows it is a variable of type pointer and not an ordinary variable, again, given that you specify (obligatory) the variable type, the compiler knows how many blocks after block located at address.
Re: What are the advantages of pointers?
With Pointers we get the functionality for the implementation of the complex data structures.After declaring a pointer it must be initialize. This approach is very important because when you declare a pointer, it contains what the box, where it is stored before contained, that is to say, any number. Otherwise, if you do not initialize your pointer, it may point to a hazardous area of your memory, which may be a piece of your program or your operating system.