1

I am looking at some sample code and cant work out what the following lines are doing:

   fcgi_streambuf cin_fcgi_streambuf(request.in);
   fcgi_streambuf cout_fcgi_streambuf(request.out);
   fcgi_streambuf cerr_fcgi_streambuf(request.err);

I dont come from a c background so the syntax looks a bit odd - each line is calling a function in initialising a new object but i would expect at least an assignment in there. For example:

    fcgi_streambuf = cin_fcgi_streambuf(request.in);
    fcgi_streambuf = cout_fcgi_streambuf(request.out);
    fcgi_streambuf = cerr_fcgi_streambuf(request.err);

The full example code can be found here: http://chriswu.me/blog/writing-hello-world-in-fcgi-with-c-plus-plus/

4

2 回答 2

6

No, each line is defining a variable.

   fcgi_streambuf cin_fcgi_streambuf( request.in );
// ^-type-------^ ^-name-----------^  ^-params-^

Where the parameter is passed to the constructor of class fcgi_streambuf. While not 100% accurate, it might help to think of it this way:

fcgi_streambuf cin_fcgi_streambuf = fcgi_streambuf( request.in );
于 2013-03-29T23:45:29.067 回答
3

Those lines are declaring three variables of type fcgi_streambuf and calling the constructor for that type.

于 2013-03-29T23:45:30.033 回答