2

Hi I am working on a code and came by this c++ syntax. I am wondering what this exactly means.

function1(param1).function2(param2);

Does this represent function with in a function? Or something like trigger this function when the first one is over?

4
  • 6
    parashift.com/c++-faq-lite/method-chaining.html Commented Aug 14, 2013 at 18:03
  • 5
    function2 must be a method from the returned object of function1. Commented Aug 14, 2013 at 18:03
  • 3
    Why is this legitimate question on C++ FAQ list, but downvoted on SO? Commented Aug 14, 2013 at 18:34
  • 5
    @SChepurin because there are too many people here now that think people shouldn't be allowed to ask basic questions as a way of learning something. Commented Aug 14, 2013 at 19:29

3 Answers 3

23

function1 returns an object that has function2 as a member function.

Sign up to request clarification or add additional context in comments.

Comments

8
function1(param1).function2(param2);
^returns an object    ^
                      | 
                      is a member function of returned object  

Comments

8

function1 returns an object that has a method named function2.

Example function1 may return an instance of a class looking like :

class MyClass
{
public:
//  ...
    void function2( int i ); // the return value and params are just for the example

//  ...
};

MyClass function1( Type paramName ); // example of prototype of function1 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.