lundi 13 avril 2020

Can I guarantee that the address of nullptr is always 0?

I know that NULL is always 0, but why does the following code print the message?

#include <iostream>

using namespace std;

int main() {
    int* ptr = nullptr;
    if (ptr == 0) {
        cout << "Does it always work?";
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire