Skip to content

Lvalue and Rvalue

amin-amani edited this page Jun 27, 2023 · 1 revision

#include <iostream>
#include <vector>
#include <string>
#include <memory>
#include <QDebug>

void Print(const std::string&RvalueAndLvalue)
{
    std::cout<<"LandRvalue:"<<RvalueAndLvalue<<std::endl;

}
void Print( std::string&Lvalue)
{
    std::cout<<"Lvalue:"<<Lvalue<<std::endl;

}
void Print( std::string&&Rvalue)
{
    std::cout<<"Rvalue:"<<Rvalue<<std::endl;

}
int main()
{
    std::string name="john ";
    std::string family="mirror";
    //"name+family" is rvalue reference because it is temproary

    std::string fullName=name+family;


Print(name+family);
Print(name);

return 0;
}

Clone this wiki locally