matt sh
matt sh

Reputation: 1

Is there any relationship between pointers and program's performance?

I am new to C++. I got accustomed with pointer and memory allocation, but there is still some question in my mind. When we prefer references rather than pointers, is there any kind of technical distinction? Another question in my head is that is there any relationship between pointers and program performance. Let me explain, I knew that using pointers means allocating heap, but using them could potentially improve my program's performance?

Upvotes: 0

Views: 51

Answers (1)

robinsax
robinsax

Reputation: 1220

References and pointer do different things. References refer to existing variables, where as pointers are arbitrary addresses.

Here is a great write up on when to use each.

The question of performance improvements doesn't really make sense. Using the heap is necessary for a wide variety of reasons, it wasn't created for performance.

Upvotes: 1

Related Questions