I found out about std::nullptr_t , which is a type of null pointer literal, nullptr .
Then I made a small program:
#include <iostream> int main() { std::nullptr_t n1; std::cout<<n1<<endl; return 0; }
Here nullptr_t is the data type and n1 is the variable, and I'm trying to print the value of the variable. But, the compiler throws an error:
prog.cpp: In function 'int main()': prog.cpp:6:11: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'std::nullptr_t') std::cout<<n1<<endl;
Why does std::nullptr_t work with std::cout in C ++? What am I wrong here?
user7620837
source share