Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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
4  
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
1  
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

3 Answers

up vote 24 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
2  
@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
15  
@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

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

Yati

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
1  
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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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