什么是复制构造函数?我们为什么用它?我的意思是特别是在C ++语言中 [英] What is copy constructor? Why do we use it? I mean especially in C++ language
问题描述
请帮助我,如果有人知道答案,请以清晰简单的方式解释:)
提前谢谢:)
什么是复制构造函数?为什么我们使用它?它与标准构造函数的区别是什么?
我尝试过:
实际上我读过它,但我无法理解它。什么是复制构造函数?我们为什么要使用它?为什么我们必须使用它?
但我也可以'找到关于它的明确信息:)许多关于它的文章都是以困难的方式编写的。
Please,help me and if someone know answer,please explain in clear and easy way :)
Thanks in advance :)
What is copy constructor?why do we use it?what is its difference from standart constructor?
What I have tried:
Actually i read about it,but i can't understand it.What is copy constructor?why do we use it?why must we use it?
but also i can't find clear information about it :) Many of articles about it are written in difficult way.
推荐答案
最简单的是找出c ++中的copy contrsuctor是什么阅读文档。
The simplest is to find out what is copy contrsuctor in c++ is to read documentation.
T类的复制构造函数是非-template构造函数,其第一个参数是T&,const T&,volatile T&或const volatile T&,并且没有其他参数,或者其余参数都具有默认值。
A copy constructor of class T is a non-template constructor whose first parameter is T&, const T&, volatile T&, or const volatile T&, and either there are no other parameters, or the rest of the parameters all have default values.
来源:复制构造函数 - cppreference.com [< a href =http://en.cppreference.com/w/cpp/language/copy_constructortarget =_ blanktitle =New Window> ^ ]
更多信息:
C ++ Copy Constructor [ ^ ]
复制构造函数和复制赋值运算符(C ++) [ ^ ]
Source: Copy constructors - cppreference.com[^]
More at:
C++ Copy Constructor[^]
Copy Constructors and Copy Assignment Operators (C++)[^]
这篇关于什么是复制构造函数?我们为什么用它?我的意思是特别是在C ++语言中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!