where we have to use Pointer

145 pts.
Tags:
C++
C++ Pointer
hi I just want to know that where we have to use pointer??

Answer Wiki

Thanks. We'll let you know when a new response is added.

A pointer is a memory variable that contains the address of another memory variable. They were widely used in older, procedural programming languages like C. Using pointers allowed programmers to write very fast, low-level code. But pointers also exposed some security risks that were difficult to identify when the programs were being written. Pointer use is allowed in C#,

—————–

There could be many situations in which you may need to use a pointer.

Comes to mind the need to build a list of objects that needs to be able to grow without other limits than the available resources on the system.

This can be done with a linked list, using pointers.

If you use an array, you need to pre-define a maximum number of elements, and on the other hand, your program will always use the amount of memory needed to store all the elments of the array, whether it is full or not.

As mentioned by Mr.Carlosdl, pointer is required whenever the program needs to use heap memory access using dynamic memory allocation (alloc/malloc/calloc/new). In addition to allocation of dynamic memory, pointer can also be used to access file descriptors.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following