问题描述
您好,
我想知道是否有人遇到过以下g ++编译器错误消息。
我不记得曾经见过它。我解决了我的问题,但是我仍然不确定
这个消息是什么。任何
想法?
错误:无限制初始化非const引用
类型''Foo&''来自临时类型''Foo''
谢谢,
Neil
Hello,
I wonder whether anyone has ever come across
the following g++ compiler error message. I
don''t recall ever seeing it before. I solved
my problem but I am still not sure about
what this message is all about. Any
ideas?
error: invalid initialization of non-const reference of
type ''Foo&'' from a temporary of type ''Foo''
Thanks,
Neil
推荐答案
挑剔:
你的意思是它不允许将非常量引用绑定到临时的
。
(它允许你修改用户定义的非const临时对象/>
类型,因为你可以在这些对象上调用成员函数。)
Denis
Nitpicking:
You meant it doesn''t allow a non-constant reference to be bound
to a temporary.
(It does allow you to modify non-const temporary objects of user-defined
types, since you can call member functions on such objects).
Denis
挑剔:
(它允许你修改用户定义类型的临时对象
因为你可以调用非const成员这些物体的功能)。
丹尼斯
Nitpicking:
(It does allow you to modify temporary objects of user-defined types
since you can call non-const member function on such objects).
Denis
Victor
Victor
这篇关于奇怪的编译器消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!