C++问题求解答

int a = 10;
cout<<&a<<endl;   // 012FFE30(一个正常的地址)
voliate int b = 10;
cout<<&b<<endl;   //  输出为 1
网上也查了相关资料,但是一直没搞清为啥 变量b的地址变成 1了,好像voliate 也没有这个作用啊,有哪位大佬指导一下吗?
全部评论
warning: address of 'b&(1071)#39; will always evaluate to 'true&#39; [-Wpointer-bool-conversion]  -Wpointer-bool-conversion warnings trigger when a pointer which the compiler knows cannot be null is converted to a bool
点赞 回复
分享
发布于 2020-08-02 16:22
小红书
校招火热招聘中
官网直投
https://ac.nowcoder.com/discuss/365983?type=6&order=1&pos=26&page=1&channel=-2&source_id=discuss_tag
点赞 回复
分享
发布于 2020-08-02 16:27
是因为cout<<没有重载& volitate
点赞 回复
分享
发布于 2020-08-02 16:38
这个1是bool变量true,另外学着用google。。。国内资源太少了 给你个链接 https://stackoverflow.com/questions/8239262/why-is-the-address-of-this-volatile-variable-always-at-1
点赞 回复
分享
发布于 2020-08-02 19:31
谢谢各位
点赞 回复
分享
发布于 2020-08-03 08:44

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务