mercredi 2 novembre 2016

C++ Virtual operator ()() purpose here?

I'm trying to modify code I found, but I'm blocked by my lack of understanding of the purpose, importance, and/or relevance of this virtual operator:

Constructor in .h: virtual void operator()(QGraphicsItem* item, const QRectF& rect) = 0;

Call in .cpp: (*resizer_)(parentItem(), rect_);

  1. Can someone provide insight as to why this operator is necessary or useful?
  2. Am I right in thinking it takes parentItem(), rect_, and resizer_ as parameters, then modifies the value of resizer_?

Trimmed context for the constructor for reference:

class SizeGripItem : public QGraphicsItem
{
    private:

        class HandleItem : public QGraphicsRectItem
        {
            public:
                HandleItem(int positionFlags, SizeGripItem* parent);

            private:    
                SizeGripItem* parent_;
        };

    public:
        class Resizer
        {
            public:
                virtual void operator()(QGraphicsItem* item,
                                        const QRectF& rect) = 0;
        };

        SizeGripItem(Resizer* resizer = 0, QGraphicsItem* parent = 0);
        virtual ~SizeGripItem();

    private:
        void doResize();
        QRectF rect_;
        Resizer* resizer_;
};

Aucun commentaire:

Enregistrer un commentaire