19.11.  Member Selection Operators

[ fromfile: memberselect.xml id: memberselect ]

  1. pointer->memberName

  2. object->memberName

  1. The first is binary, the second is unary.

  2. The first is global and not overloadable; the second is an overloadable member function.

  1. STL style iterators

  2. QPointer, QSharedDataPointer, QSharedPointer, QWeakPointer, QScopedPointer, QExplicitlySharedDataPointer

  3. auto_ptr, the STL smart pointer

Example 19.21 shows part of the definition of QSharedPointer.

Example 19.21. src/pointers/autoptr/qsharedpointer.h

template <class T>
class QSharedPointer {
public:
    QSharedPointer();
    explicit QSharedPointer(T* ptr);
    T& operator*() const;
    T* operator ->() const;

    bool isNull() const;
    operator bool() const;
    bool operator!() const;  
    // [ ... ]
};

  [. . .]
  QPointer<QIntValidator> val = new QIntValidator(someParent);
  val->setRange(20, 60);
  [. . .]