Skip to content

Instantly share code, notes, and snippets.

@orontee
Created September 25, 2013 10:00
Show Gist options
  • Save orontee/6697545 to your computer and use it in GitHub Desktop.
Save orontee/6697545 to your computer and use it in GitHub Desktop.
#include <iostream>
bool false_val;
bool other_false_val = bool();
int main()
{
bool true_val();
bool val;
bool *ptr();
bool *null_ptr(0);
bool *other_ptr;
std::cout << "Global initialization (bool): " << false_val << '\n'
<< "Other global initialization (bool): " << other_false_val << '\n'
<< "Default initialization (bool): " << true_val << '\n'
<< "Uninitialized (bool): " << val << '\n'
<< "Default initialization (pointer): " << ptr << '\n'
<< "Is it null? " << (nullptr == ptr) << '\n'
<< "Default initialization (pointer): " << null_ptr << '\n'
<< "Is it null? " << (nullptr == null_ptr) << '\n'
<< "Uninitialized (pointer): " << other_ptr << '\n'
<< "Is it null? " << (nullptr == other_ptr) << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment