Possible Duplicate:
When do I use a dot, arrow, or double colon to refer to members of a class in C++?
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
In the code above, what does -> mean? Thanks.
It means the object on the left side of the arrow is a pointer to an instance of a class or structure, and the name on the right is a member of that class or structure.
In the context:
it means that
uiis a pointer to an instance of the classUi::MainWindowand thesetupUI(this)is an invocation of thesetupUImember function of that class with the parameterthis.When you have an actual instance of a class (or structure) instead of a pointer, then you use the notation:
Strictly, you can also write:
However, you will rightly be ostracized if you write code like that rather than using the
->arrow operator.