PDA

View Full Version : The -> Operator



keifer
11th March 2008, 00:13
I'm still rather new to both c++ and qt4, so please bear with me. My question is what exactly does the -> operator do? I've looked in both the Qt4 Tutorial and my copy of the C++ Primer, and I've yet to find anything on it.

Basically I wish to know why:

myButton->setEnabled(!text.isEmtpy());

differs from:

myButton.setEnabled(!text.isEmpty());

jacek
11th March 2008, 02:24
a->b is equivalent of (*a).b (in other words: it allows you to access members of a class or structure if you have a pointer to it).

In your example, the first myButton variable is a pointer to an object, while the second one is the object itself.