What makes pointers different to normal variables, and what is the point of using them over normal variables? I want a long and detailed description please :D

Recommended Answers

All 2 Replies

There are literally hundreds of tutorials about pointers online. I'd recommend reading as many as you can and asking here if you have specific questions.

Dave

There are a few big benifits of pointers and references.

For example if you have a function that calculates the result of a x^2 equation you would want it to return both the roots.
This can be achived by passing a reference or pointer to variables that will contain the roots after the calculations.

Like such:

Int calculate(float p, float a, float q, float& x1, float& x2);

Other uses includes:
Creating a pointer and later telling what to point at using the new keyword, called dynamic memory.
Having one pointer which can point at two diffrent variables which changes during runtime.
Avoiding passing big data structures as arguments( copying isn't good).
Creating linked lists.
In 3d graphic pointers are often used when swapping between the back and front buffer.

Here's more material:
Pointers @ cplusplus.com
Stackowerflow.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.