Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • “they probably didn't want to mess with such core concept of the language” They already completely removed pointers, also removing null wouldn't be that big of a change, I think. Commented Dec 15, 2013 at 16:04
  • 2
    @svick For Java, references are replacement for pointers. And in many cases, pointers in C++ were used in a same way as what Java references do. Some people even claim that Java does have pointers (programmers.stackexchange.com/questions/207196/…) Commented Dec 15, 2013 at 16:05
  • I have marked this as the correct answer. I would like to upvote it but I have not enough reputation. Commented Dec 15, 2013 at 16:25
  • 1
    Agree. Note that in C++ (unlike Java and C), being null-able is the exception. std::string cannot be null. int& can't be null. An int* can, and C++ allows unchecked access to it for two reasons: 1. because C did and 2. because you're supposed to understand what you're doing when using raw pointers in C++. Commented Dec 16, 2013 at 10:21
  • @MSalters: If a type does not have a bit-copyable default value, then creating an array of that type will require calling a constructor for every element thereof before allow access to the array itself. This may require useless work (if some or all elements will be overwritten before they are read), may introduce complications if the constructor for a later element fails after an earlier element has been built, and may end up not really accomplishing much anyway (if a proper value for some array elements could not be determined without reading others). Commented Jan 28, 2014 at 18:22