Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Should I be programming in C to get "used" to this?</p> </blockquote> <p>No, you shouldn't. C used to be a good introduction to C++ when C++ was mostly thought of as "C but with classes". C++ has evolved so much from that mindset that writing C code in C++ makes for very very bad C++ code.</p> <blockquote> <p>What should I be doing to get used to pointers if I've never used them coming from a language such as Java?</p> </blockquote> <p>Knowing how to use pointers in C++ implies several key areas (and you should probably learn them one after the other):</p> <ul> <li><p>pointer arithmetic (adding and substracting pointers and integers, usage of zero pointer, pointers and arrays, operations with pointers); this is the part C++ shares with C.</p></li> <li><p>pointers to functions (this part is also shared with C).</p></li> <li><p>pointer casting (static_cast, dynamic_cast, ...). This part is C++ specific. You could also define your own cast type and experiment with that a bit (and have a look at boost::lexical_cast as an example).</p></li> <li><p>pointers to member objects and member functions.</p></li> <li><p>RAII for pointers and various smart pointer implementations: circularly-linked pointers, reference-counted pointers (boost::shared_ptr), unique pointers (std::auto_ptr), scoped pointers.</p></li> <li><p>wrapping function pointers in functor classes (see std::tr1::function or boost::function).</p></li> <li><p>object references and how they are like and unlike pointers; Where to use references and where to use pointers.</p></li> <li><p>the similarities between pointers and iterators.</p></li> <li><p>using <code>operator*</code> and <code>operator-&gt;</code> to simulate pointer-like behavior for an object (and when not to abuse this).</p></li> <li><p>pointers and <code>const</code>ness / mutability: what is the difference between a pointer, a const pointer, a pointer to a const value and a const pointer to a const value (and when to use each), and similar using mutable pointers.</p></li> </ul> <p>Current best practices in C++ advice against using pointers in your code unless they are managed automatically by your code (through RAII for example).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload