阅读背景:

为什么在这种情况下要调用r值引用构造函数?

来源:互联网 
#include<iostream>
using namespace std;

struct B{};

struct A
{
    A(const B &)
    {
        cout<<"A(const B &)"<<endl;
    }
    A(B &&)
    {
        cout<<"A(B &&)"<<endl;
    }
};

A get()
{
    B b;
    return b;
}

int main()
{
    get();
}
#include<iostream>
using namespace std;

struct



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: