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.

  • 5
    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. – user7043 Sep 4 '11 at 18:50
  • 3
    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. – user117175 Feb 1 '14 at 10:50
  • you can understand them! – Jonathan dos Santos Feb 1 '14 at 11:15
  • Yes, pointer are one of many key concept to learn C++ – Taco Feb 2 '14 at 0:41

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.

| improve this answer | |
  • 3
    @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
  • 17
    @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 '14 at 1:01
  • 4
    @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 '14 at 8:08

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.

| improve this answer | |
  • 2
    Actually, truly understanding Java also means understanding pointer (although not necessarily pointer arithmetic), as pointers are much more prevelant in that language ;) – user7043 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
  • 2
    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
  • But understanding the difference between class types (reference semantics) and primitive types (value semantics) is very fundamental for understanding Java. Unlike C++, class instances in Java are ALWAYS constructed on the heap (with the new operator) and referred to by reference, so you will basically be dealing with pointers for any program beyond Hello World, though you may not even realize it. The same is true for C#, although there are subtle differences (it allows complex, class-like types with value semantics which it calls "structs"). – chris May 9 '14 at 9:52
  • Besides, Java never "dropped" pointers (as evidenced by the beloved NullPointerException), it just calls them "references" and hides away the gory details. – chris May 9 '14 at 10:09

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

| improve this answer | |

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.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.