小编cat*_*our的帖子

我能保证nullptr的地址始终为0吗?

我知道NULL总是如此0,但是为什么下面的代码会打印该消息?

#include <iostream>

using namespace std;

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

c++ nullptr c++11

1
推荐指数
1
解决办法
718
查看次数

标签 统计

c++ ×1

c++11 ×1

nullptr ×1