0

I've been working on a Qt/C++ project, using QtDbus, and am confused by a particular piece of syntax during my learning of the process. I've been reading this tutorial, and am wondering about the following piece of syntax in ChatWindow.cpp:

ChatWindow::ChatWindow(demo::Chat& chatInterface, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ChatWindow),
    m_userName(),
    m_users(),
    m_chatInterface(chatInterface)
{

I'm wondering what the variables followed by () mean. I thought the : parent syntax was just for multiple class inheritance. I'm sure I'm missing something very simple, but hugely appreciate any input, as I don't even know what I should be trying to Google.

Thanks!

n00b
  • 127
  • 3
  • 8

1 Answers1

0

I thought the : parent syntax was just for multiple class inheritance

No it's not. It's called an initialization list. The short answer is that it allows you to initialize the member variables of your class to a particular value at the time that they are constructed.

Chris
  • 17,119
  • 5
  • 57
  • 60
  • Aha, thanks! I knew I must be missing something really basic. I'll confirm your answer as soon as the site lets me. – n00b Sep 22 '13 at 21:25