How does this function call work: functionOne().functionTwo()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raptoger
    New Member
    • Mar 2008
    • 4

    How does this function call work: functionOne().functionTwo()

    I have seen this syntax in some code and can't figure it out.
    Other times is function()->function2()
    I thought we could do that only for class/object members, structs,
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Originally posted by raptoger
    I have seen this syntax in some code and can't figure it out.
    Other times is function()->function2()
    I thought we could do that only for class/object members, structs,
    the method function() would be returning a object and thats wahy we arecalling like this

    Raghuram

    Comment

    • raptoger
      New Member
      • Mar 2008
      • 4

      #3
      Originally posted by gpraghuram
      the method function() would be returning a object and thats wahy we arecalling like this

      Raghuram
      Could you please elaborate a bit more? I need to have this clear because I'm studying QT and C# and I'm seeing this syntax for the first time.

      I see something like this in QT: filesMenu.addAc tion().addMenu( "&File");
      I see something like this in C#: server.GetLastE rror().Message;

      Thanks

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        In the first example, the addAction() method presumably returns the added Action class (I'm extrapolating, the names aren't necessarily exact), from which you then call its addMenu method with that parameter. In the second, the getLastError() method would return an Error object, from which you call the Message() method, which presumably returns a string describing the error.

        Comment

        • raptoger
          New Member
          • Mar 2008
          • 4

          #5
          Originally posted by Laharl
          In the first example, the addAction() method presumably returns the added Action class (I'm extrapolating, the names aren't necessarily exact), from which you then call its addMenu method with that parameter. In the second, the getLastError() method would return an Error object, from which you call the Message() method, which presumably returns a string describing the error.
          That is pretty good ! Concept understood.
          Thanks for the time

          Comment

          Working...