Created
September 25, 2013 10:00
-
-
Save orontee/6697545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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