这是什么意思? std :: istream response_stream(& * response_); [英] What does it mean? std::istream response_stream(&*response_);

查看:93
本文介绍了这是什么意思? std :: istream response_stream(& * response_);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟踪了其他人的C ++代码;包含一个声明

std :: istream response_stream(&* response_);

其中response_定义为

boost :: asio :: streambuf * response_;



在回复之前对用户&和*有意义吗

&* response_





&* response_不等于'response _'?

I traced C++ codes from others; containing a statement
std::istream response_stream(&*response_);
where response_ is defined as
boost::asio::streambuf * response_;

Does it make sense to user & and * before response_ like
&*response_
?

Isn't "&*response_" equal to just 'response_'?

推荐答案

你没有添加太多的代码来澄清,但是因为它被写成它看起来像一个函数声明 - 在这种情况下它是有道理的。



将参数定义为&在c ++函数声明中意味着参数通过引用传递,如下一个示例中所示。



You did not add much code to clarify, but as it is written it looks like a function declaration - in that case it makes sense.

Defining a parameter as & in a c++ function declaration means that the parameter is passed by reference, as in the next example

void same(int &n);  // declaration of the prototype with a reference
int main(){
    int iA = 5;   // Define a number
    same(iA);     // pass the variable to ur function BY REFERENCE
    cout << iA; // Without the reference passing I should see 5; By reference I can 
                // change the value of the parameter, so now iA equals 6;
    return 0; // Exit from main
}
void same(int &n){
    n = 6;
}





所以通过传递一个参数作为& * response_我传递对象的引用响应指出_



我希望我已经足够清楚了(英语不是我的主要语言)并帮助过你。



编辑:我发现了一篇关于CodeProject的文章指针指针和指针引用 [ ^ ],也许对你有帮助。



- Denis



So by passing a parameter as &*response_ I'm passing a reference to the object pointed by response_.

I hope I have been clear enough (English is not my primary language) and to have helped you.

I found an article on CodeProject Pointer to Pointer and Reference to Pointer[^], maybe it helps you.

- Denis


这篇关于这是什么意思? std :: istream response_stream(&amp; * response_);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆