Take the 2-minute tour ×

Well, I love C++, I have been using it for a while: I like all the libraries (Allegro, SDL, QT, Ogre, etc.), but I have a problem: I don't understand pointers.

Do I really need them ? I just program for fun: but I want to study it some day. Thanks.

share|improve this question
You can probably get quite far without using raw pointers (T *), but you should understand the general concept (indirection), or you'll have a hard time with pretty much any language. And from that to understanding pointers (even if you're scared by the amount of care that's required to handle them safely and without leaking) isn't much of a leap in my experience. –  delnan Sep 4 '11 at 18:50
Pointers are everywhere. if you ignore them and pretend they're aliens, They'll sneak out from under the bed and give you nightmares ./ I KNOW –  Adel Feb 16 '12 at 5:03
Pointers is one of the core concepts of c++. If you want to enjoy with programming then pointers basics must be learn. Because pointers will gives you the understanding of the memory use and you will learn how to write efficient and generic code. –  mobi Feb 1 at 10:50
you can understand them! –  jonathan Feb 1 at 11:15
Yes, pointer are one of many key concept to learn C++ –  Taco Feb 2 at 0:41
add comment

5 Answers

up vote 36 down vote accepted

Yes, definitely. They are a fundamental concept of programming, no matter if you program in a language that supports direct pointer management or not, but even more so if you do.

share|improve this answer
@dysoco Once you understand that ordinary variables (or better, objects) are just things stored in the computers memory, and that pointer variables do nothing more than just store memory addresses, you will realize how easy this whole concept is, just keep at it. –  Christian Rau Sep 4 '11 at 19:03
@dysoco I did learn that when I was 12, and only by myself - internet wasn't what it is now and I did had it at home anyway, so yes, you definitively can do it at 14. As a more general advice : never use your age as an excuse to procrastinate. This will lead you nowhere. –  deadalnix Sep 4 '11 at 19:29
I disagree that "[pointers] are a fundamental concept of programming." Not all languages even have them, so I think that alone refutes your assertion. –  Randall Schulz Feb 2 at 1:01
@RandallSchulz: Indirection is a fundamental concept in programming, though, whether it's accomplished through array indexes or offsets from an address or some other means; there are indirect addressing modes at the assembler level. C and C++ are unique in that they provide distinct pointer types, but pointer operations are pretty universal. –  John Bode Feb 2 at 8:08
add comment

Pointers are an integral part of C++ and though you can avoid them and use references instead, you will find a lot (A LOT) of code that relies on the efficiency and power of pointers. You cannot write a QT GUI app without using pointers.

I suggest you get a good book on pointers and master them. Even experts sometimes get confused with pointers, but eventually, the power and the flexibility that comes with pointers is just too lucrative. Try this and this

PS: DO NOT make a transition to Java, just because you don't get pointers. You will, and you WILL understand them, if you're passionate enough.

share|improve this answer
Actually, truly understanding Java also means understanding pointer (although not necessarily pointer arithmetic), as pointers are much more prevelant in that language ;) –  delnan Sep 4 '11 at 19:08
@delnan But if you confront someone who only ever learned Java with direct pointers, they look at you and say "huh?" (disclaimer: need not apply to everyone). Therefore direct pointers are a much more fundamental concept, as they don't abstract away the underlying machine architecture into some abstract equality-vs-identity question. –  Christian Rau Sep 4 '11 at 19:17
exactly, Java dropped pointers to maintain ease of use, and the fact that programmers never have to learn pointers(they way they'd have to in C/C++) in order to use the language effectively can cause giddiness when pointers are mentioned to most of them. References in Java require some understanding of pointers, but the main thing about pointers is not being able to use them, but about not misusing them :) (segfault, anyone?) –  yati sagade Sep 4 '11 at 19:28
add comment

Yes, you need them, if you want to use libraries like the one you mention, that are designed to rely on them.

share|improve this answer
add comment

Pointers is one of the great features that c/C++ provides. You can write the programs in C++ without knowing and without understanding the concept of pointers to some extent.

But You can write the program in better way by knowing them. Also in some cases it is very essential. So, it is always good idea to learn and understand the concept of pointers.

share|improve this answer
add comment

Joel had something to say about understanding pointers and the like in his The Perils of JavaSchools. It's on the same line with what everybody around here have already said: you need them like the air!


Now that should get you started!

I found that a great resource for learning pointers is Pointers on C by Kenneth Reek.

share|improve this answer
add comment

protected by Community Feb 2 at 1:33

