gpt4 book ai didi

c++ - 一行复制构造函数

转载 作者:太空宇宙 更新时间:2023-11-04 16:14:26 24 4
gpt4 key购买 nike

<分区>

通过了解复制构造函数的创建方式,我遇到了这个示例:

class MyClass 
{
int x;
char c;
std::string s;
};

编译器将其复制为:

 MyClass::MyClass( const MyClass& other ) : x( other.x ), c( other.c ), s( other.s )
{}

: x( other.x )... 和函数头行在同一行是什么意思?它是如何工作的?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com