小编Exc*_*yon的帖子

一行复制构造函数

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

class MyClass 
{
      int x;
      char c;
      std::string s;
};
Run Code Online (Sandbox Code Playgroud)

由编译器复制为:

 MyClass::MyClass( const MyClass& other ) : x( other.x ), c( other.c ), s( other.s )
  {}
Run Code Online (Sandbox Code Playgroud)

: x( other.x )...与函数标题行在同一行中的含义是什么?它是如何工作的?

c++ class function

0
推荐指数
1
解决办法
426
查看次数

标签 统计

c++ ×1

class ×1

function ×1