Unable to print the value of nullptr on screen

后端 未结 3 960
北荒
北荒 2020-12-06 18:33

I was reading about nullptr and doing workout on g++ and also on VS2010.

When I did

#include 
using namespace std;

aut         


        
3条回答
  •  臣服心动
    2020-12-06 18:43

    The pointer literal is the keyword nullptr. It is a prvalue of type std::nullptr_t.

    Type nullptr_t should be convertible to T*, but compiler has no operator << for nullptr_t and don't know to which type you want to convert nullptr.

    You can use this

    cout << static_cast(nullptr) << endl;
    

提交回复
热议问题