Friend函数里面的代码 [英] Friend Function inside code

查看:145
本文介绍了Friend函数里面的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发布了问题。可以从响应中检查代码。

I posted a question earlier . The code could be checked from the response.

我的问题是帖子的作者张贴在移动构造函数

My question is the author of the post posted this in the move constructor

swap(*this,that); 

这在复制赋值运算符中

swap(that);

现在我熟悉的朋友函数的概念,并做了更多的阅读,关于为什么第二个语句只有一个参数,而交换方法需要两个参数。如果有人能澄清第二个语句,为什么它只传递一个参数,我将不胜感激。

Now I am familiar with the concept of friend functions and have done more reading on it however I am still baffled as to why the second statement only has one parameter whereas the swap method requires two parameters. I would appreciate it if some one can clarify the second statement and why its just passing one parameter ?

推荐答案

答案,那是一个错字。两个应该都是

As the other of said answer, that was a typo. Both should have been

swap(*this,that); 

Jonathan Wakely指出了我的错误,我已更正了错误。

Jonathan Wakely pointed out my error and I have corrected it.

没有魔法,你不知道,hooray!

There was no magic involved that you didn't know, hooray!

这篇关于Friend函数里面的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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