1

I'm moving from C# to C++, one of priority topic for me is pointer. I'm reading some book and some blog post about pointer and I understand its basic concept. Now I want to learn about pointer by practicing it.

I try to search on google, unfortunately not thing found. Are there anything can help me study and practices on C++ pointer?

Anonymous
  • 9,366
  • 22
  • 83
  • 133
  • 3
    Languages aren't houses, you don't move from one to another. You forget you know anything and start that way. (Which means you get [a book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list).) If you don't, you'll just form bad practices and false information. – GManNickG Aug 26 '10 at 06:12
  • 1
    possible duplicate of [How to learn C pointers?](http://stackoverflow.com/questions/1692142/how-to-learn-c-pointers) – Ben Voigt Aug 26 '10 at 06:15
  • That said, [here's a mini-book on pointers](https://docs.google.com/fileview?id=0B2oiI2reHOh4M2MzNzYwYzQtMGZkNC00NTljLWJiM2UtOGI0MmRkMTMyZGY4). I haven't read it, but it seems awesome. (And the author is known to be knowledgeable.) – GManNickG Aug 26 '10 at 06:23
  • @Ben: Thanks for your link. @GMan: That book is great for me. On my current book it mention only how it work and basic concept about pointer. – Anonymous Aug 26 '10 at 06:32
  • +1: for asking about how to learn!. Very rare nowadays – Chubsdad Aug 26 '10 at 09:17

3 Answers3

2

Just google for "learn C pointers". For example, you'll find stuff like http://computer.howstuffworks.com/c20.htm

Once you understand what a pointer is, what it does, and how it is managed, start using C++ smart pointers which take care of some of the grunt work for you.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • 1
    +1 for this instead of radman's answer: When learning C++, you should definitely learn the ins and outs of pointers and how to manipulate them before you delegate pointer handling to smart pointers....IMHO :) – Anthony Aug 26 '10 at 06:24
  • I agree that understanding the fundamentals of pointers is important. But I think it is more important to get used to the idiom of smart pointers from the outset, to avoid bad habits. Obviously doing both at the same time would be ideal. – radman Aug 26 '10 at 08:30
0

I would agree with GMan's comment that a good C++ book is the way to go to do this properly.

Aside from that the most important thing when learning pointers in C++ is to use smart pointers. These can be found in the appropriate boost library. Using these from the outset will save you much pain in the future.

Also boost is a GREAT resource for any C++ programmer and you should familiarise yourself with it.

radman
  • 17,675
  • 11
  • 42
  • 58
  • Just want to mention that while smart pointers take out the chore of pointer management, you still need to know C++ pointers very well, in order to use smart pointers correctly. If the word "pointer" sounds scary, try think of it as "reference" or "handle". To help yourself learn pointers, find a textbook on Data Structures and Algorithms, and do the exercises using pointers. Also, familiarize with the "reference counting" concept early on. – rwong Aug 26 '10 at 06:28