For some reason I'm getting the error "nullptr" undeclared identifier?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
int main()
{
int a(20);
int* pnbr(nullptr);
std::cout << "the value of a = " << a <<std::endl;
std::cout << "the address of a = " << std::hex << &a <<std::endl;
pnbr=&a;
std::cout << "pnbr has the same address as (a) which is = " << std::hex << pnbr <<std::endl;
return 0;
}
am I missing something here? I'm following a tutorial and their program compiles I'm using the exact same code....
changing it to = 0 instead of (nullptr) works I'm just wondering why this code doesn't compile and his does...
"nullptr" only works with C++ 11, and when I compiled this with C++ 11, it worked, but did not with C++ 98. By default compilers use C++ 98, which calls for 0, rather than nullptr.