Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simple answer is that it is a design decision. The slightly longer answer is that pointers in C++ are only necessary for memory manipulation, which is not a concept that applies to Java (see below).</p> <p>Java envisions a fairly systematic, object-oriented programming model, and all class-based types are essentially <em>always</em> handled through a pointer, and so this fact isn't exposed to the user at all.</p> <p>Raw pointers in C++ aren't very necessary in high-quality, systematic and idiomatic programming, either. What raw pointers do allow you to do (namely pointer arithmetic) is generally considered "unsafe", and so it is simply left out of Java altogether.</p> <p>Note by the way that many things people attempt to do with pointers in C and C++ is actually undefined behaviour. Using pointers correctly leaves you with a fairly restricted set of options, most of which can be done better in idiomatic C++.</p> <p>About the only <em>real</em> use for pointers is direct memory manipulation. Since Java doesn't want you to do that (and in fact its garbage-collected memory management would actively interfere with and be broken by manual memory manipulation), there's no need for explicit pointers.</p> <p><em>After your update:</em> The last paragraph is (in my opinion) the most striking explanation: In C++ you <em>need</em> to be able to write your own memory managing code (cf. "allocators"). And memory <em>has</em> to be handled via pointers. So my strict answer is that you need pointers in C++ when you're implementing the memory management, and never otherwise.</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.
 

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