c++ copy construct

来源:互联网 发布:为知笔记 markdown 编辑:程序博客网 时间:2024/06/05 08:41
ExpressionPost-conditionsT u = v;The value of u is equivalent to the value of v.

The value of v is unchanged

T(v)The value of T(v) is equivalent to the value of v.

The value of v is unchanged.



CopyConstructible


Specifies that an instance of the type can be copy-constructed from an lvalue expression.
指定一个类型的实例可以通过Copy-Constructed赋值。


1、T u = v;  

在C++语言中,对于对象赋值是通过对象的Copy-Construct方法实现。

2、T(v)

在C++语言中,如果把class对象作为参数传递,编译器会调用Copy-Construct来实现对形参的赋值。

0 0