[Development] QTCS2019 Notes from QtQml session

Ulf Hermann ulf.hermann at qt.io
Mon Nov 25 12:35:20 CET 2019


> Il 25/11/19 10:25, Eike Ziller ha scritto:
>>> ?
>> Similar things can happen in C++ with method names.
>> C++ got the ‘override’ keyword to make these breakages detectable by 
>> tooling.
>> It looks to me like the case id==propertyname would also be detectable 
>> by tooling?
> 
> What do you mean? Can you make an example? The whole point of shadowing 
> in C++ is to make sure that the above does NOT break.

Consider QSomething to be Qt code and the rest user code:


class QSomething {
public:
//    struct b {};
//    void b() { qDebug() << Q_FUNC_INFO; }
};

void b() { qDebug() << Q_FUNC_INFO; }

class c : public QSomething {
public:
     void x() { b(); }
};

int main(int argc, char *argv[])
{
     c ttt;
     ttt.x();
}


Add one of the "b" to QSomething and the user code silently stops working.

Ulf


More information about the Development mailing list