以下两个语句在语义上是否相同?(Are the following two statements semantically same?)

系统教程 行业动态 更新时间:2024-06-14 17:04:02
以下两个语句在语义上是否相同?(Are the following two statements semantically same?)

以下两个语句在语义上是否相同?

#1 person p("Rahul", 20);

#2 person const &p = person("Rahul", 20);

编辑:

对不起,我的意思是询问以下两者在语义上是否相同:

#1 person const p("Rahul", 20);

#2 person const &p = person("Rahul", 20);

Are the following two statements semantically same?

#1 person p("Rahul", 20);

#2 person const &p = person("Rahul", 20);

EDIT:

Sorry, I meant to ask whether the following two are semantically same:

#1 person const p("Rahul", 20);

#2 person const &p = person("Rahul", 20);

最满意答案

他们不是。 然而,这种区别仅受第二种情况需要C ++ 03可访问的拷贝构造函数的影响(即使拷贝构造函数调用实际上没有完成)

// works with #1 fails with #2 struct f1 { f1(string, int); private: f1(f1 const&); };

They are not. However, the difference are affected only by the fact that the second case needs a copy constructor to be accessible in C++03 (even if the copy constructor call is not actually done)

// works with #1 fails with #2 struct f1 { f1(string, int); private: f1(f1 const&); };

更多推荐

本文发布于:2023-04-24 20:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/19d373317a93d7629f83c3094d0bff92.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语义   语句   两个   semantically   statements

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!