Why did C++11 introduce the nullptr constant when we already have NULL?

What will be an ideal response?


nullptr gives us type safety. NULL is used semantically as an empty pointer,
but the compiler also treats it like the number 0. This means a 0 can be substituted
anywhere for NULL. This could cause problems if we ever need to differentiate between
0 and the empty pointer. nullptr solves this problem because it is not the same as 0. It
is a new constant that represents an empty pointer.

Computer Science & Information Technology

You might also like to view...

Which of the following statements is false?

a. Each class can define a constructor for custom object initialization. b. A constructor is a special member function that must have the same name as the class. c. C++ requires a constructor call for every object that’s created. d. A constructor cannot specify parameters.

Computer Science & Information Technology

Which is the function body for the Jeopardy constructor?

``` class TVGame { protected: string host; string game; public: TVGame(string h, string g); GoToCommercial(); // add the StartGame function here }; class Jeopardy : public TVGame { private: int score; public: Jeopardy(string h, string g, int s); // add StartGame function here }; ``` A. { s = score; } B. { g = h; } C. { h = score; } D. {score = s;}

Computer Science & Information Technology

Macros that run automatically when an Access database is opened

a. .Exe b. Startup c. AutoStart

Computer Science & Information Technology

The named range from a selection for the VLOOKUP function has to use the top row of the table array

Indicate whether the statement is true or false

Computer Science & Information Technology