错误消息C4239非标准扩展 [英] Error Message C4239 Non Standard Extension

查看:423
本文介绍了错误消息C4239非标准扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告1警告C4239:使用了非标准扩展名:``默认参数'':从``CSize''转换为``CSize&''

我有四个这样的错误.使用Visual Studio 2010

这是代码....

Warning 1 warning C4239: nonstandard extension used : ''default argument'' : conversion from ''CSize'' to ''CSize &''

I have four of these errors. Using Visual Studio 2010

This is the code....

void="" dword="" csize="" szicon="CSize(0," lpcrect="" lprectbounds="NULL," dwidtool="0);"


[edit]修复了标签,但是我相信第一部分实际上并不属于这里,或者在粘贴到本文中时被弄乱了吗? -Stefan_Lang [/edit]


[edit]fixed the tags, but I believe the first part doesn''t actually belong here, or got mangled when pasted into this post? - Stefan_Lang[/edit]

推荐答案

显然,您已声明变量szicon的类型为CSize&.但是,引用类型应该是const,这就是警告所表示的含义.改为将类型更改为const CSize&,如下所示:
Apparently you declared the variable szicon to be of type CSize&. Reference types are supposed to be const though, and that is what the warning expresses. Change the type to const CSize& instead, like this:
const CSize& szicon = CSize(...);


就是说,上面的代码甚至都不起作用,因为右侧创建了一个CSize类型的临时对象,该对象立即被销毁,因为它没有分配给实际变量!为什么不这样声明变量:


That said, the above wouldn''t even work, because the right hand side creates a temporary object of type CSize which gets immediately destroyed because it isn''t assigned to an actual variable! Why don''t you just declare a variable like this:

CSize szicon(...);

?
这也应该工作.

?
This should work just as well.


这篇关于错误消息C4239非标准扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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