Introduction to C++ 11 Series – Part 2, the nullptr

March 22, 2013

nullptr is a real NULL pointer.

Look at this sample:

void nullptr_overload(int i) { cout << "int" << endl; } void nullptr_overload(int *p) { cout << "int *" << endl; }

void main()






Can you guess the result?


The new nullptr is not another representation of 0 (zero) but it is an instance of a new type. Here are some facts:

• nullptr is a reserved keyword for a constant (rvalue) of type std::nullptr_t

• The size of this constant is the same as sizeof(void*) (makes sense, after all it represents a null pointer)

• You can:

– copy it

– Throw it as an exception

– Use it with the typeid expression

• You can’t take the address of it

You can read more about it here.

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


one comment

  1. rooleatlyMay 16, 2013 ב 07:35

    Excellent Post.thanks for share..far more wait ..

    [URL=]stride jacket lululemon[/URL]