为什么visual studio在这种情况下不优化构造函数 [英] why visual studio does not optimize constructor in this case

查看:76
本文介绍了为什么visual studio在这种情况下不优化构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


为什么visual studio在这种情况下不优化构造函数?我不明白MSDN提到了什么,


如果使用不同的命名对象,编译器无法优化。为什么?


http://msdn2.microsoft.com/en-us/library/ms364057(vs.80).aspx

Hello everyone,


Why visual studio does not optimize constructor in this case? I do not understand what the MSDN mentioned,

if use different named object, compiler can not optimize. Why?

http://msdn2.microsoft.com/en-us/library/ms364057(vs.80).aspx

展开 | 选择 | Wrap | 行号

推荐答案

如果你写的(主要是),编译器可能会优化

Maybe the compiler would optimize if you wrote (in main)

展开 | 选择 | Wrap | 行号


这是我期望的输出:


我在构造函数中

我在构造函数中

我在复制构造函数中


因为在main()中:
This is the output I would expect:

I am in constructor
I am in constructor
I am in copy constructor

because in main():
展开 | 选择 | Wrap | 行号


谢谢chroot,

Thanks chroot,



如果你编译器可能会优化写道(主要)

Maybe the compiler would optimize if you wrote (in main)

展开 | 选择 | Wrap | 行号


这篇关于为什么visual studio在这种情况下不优化构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆