【问题标题】:What the heck is this C++ syntax called? [duplicate]这个 C++ 语法到底叫什么? [复制]
【发布时间】:2011-06-10 00:19:57
【问题描述】:

可能重复:
What is this weird colon-member syntax in the constructor?

我在 Qt 应用程序的构造函数中到处都能看到它,但我不知道它叫什么。我正在尝试查找有关它的文档。

Browser::Browser(QTextBrowser& textBrowser, QObject* parent /*= 0*/)
: // <- What
m_textBrowser(textBrowser), // <- is
QObject(parent) // <- this stuff?
{
}

我为我的新手道歉。

【问题讨论】:

  • 买一本好的 C++ 书,你可能会立刻明白。

标签: c++ constructor


【解决方案1】:
【解决方案2】:

这是一个构造函数initialization list

【讨论】:

    【解决方案3】:

    这是一个构造函数初始化列表。在您的示例中,它看起来像是用于初始化数据成员和基类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-17
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 2016-11-06
      • 1970-01-01
      • 2016-12-18
      • 2016-06-02
      相关资源
      最近更新 更多