复制构造函数理论 [英] Theory of copy constructor

查看:77
本文介绍了复制构造函数理论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们使用复制构造函数复制对象?

why we copy a object using copy constructor?
if we not copy an object then what happen and if i copy a object then what happen?

推荐答案

Google是您的朋友...
比我们更好地给出了浅拷贝和深拷贝等之间差异的详细解释.您会在互联网上找到更完整的信息...

链接1
Google is your friend...
Better than us give long explanations of the differences between shallow and deep copies, etc. you will find more complete information out there in the internet...

Google Search: C++ copy constructor.

More specific links: Link 1 Link 2


我认为您现在已经过分了.这是您在同一主题上的第5或第6个主题(到目前为止,我已至少删除了4个重复主题).

如果根本没有复制构造函数,则将无法调用采用非引用参数的方法.您也永远无法将一个对象分配给另一个对象.或简而言之,编程语言的功能将受到严重限制.
I think you are overdoing this at this point. This is your 5th or 6th thread on the same topic (I have deleted at least 4 duplicates so far).

If there were no copy constructors at all, you would not be able to call a method that takes non-reference arguments. Nor would you ever be able to assign one object to another. Or in short, the capabilities of the programming language would be very seriously limited.


我认为这就是所谓的理论",
阅读第12.8节
ISO/IEC JTC1 SC22 WG21 N3092 [ ^ ]

您可能最好阅读以下内容:
C ++ 2nd Edition中的思考 [
I think this is about as "theoretical" as it gets,
read section 12.8 ISO/IEC JTC1 SC22 WG21 N3092[^]

You might be better off reading:
Thinking in C++ 2nd Edition[^] by Bruce Eckel

It''s a free electronic book

Regards
Espen Harlinn


这篇关于复制构造函数理论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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