Search code examples
c++qtclasscall

class->methode1()->methode2() what does it mean?


Im introducing myself to QT right now and often comming across calls like class->methode1()->methode2(). What does this mean? methode1() would be a methode of class, but what about methode2() and how does this notation work out?

Can i split this call to class->methode1() and class->methode2() and get the same result?

Is this C++ or QT specific?


Solution

  • class->methode1() returns a pointet to an object that provides a method methode2 you can call immediately. By doing this you create anonymous objects (rvalues if I am not wrong) and you call methods on those objects. You cannl actually say

    class2 = class1->methode(); and then call class2->methode2(); to achieve the same. (pseudo-code)