I just made a function that takes a rvalue reference as parameter but if i pass '67', it works but let's say that "int&& ref = 67", if i pass ref as parameter it throws error.
#include <iostream>
using namespace std;
void func(int&& a){
std::cout << a << " from rvalue" << std::endl;
}
int main(){
int&& ref = 6;
//func(ref); // error
func(6); // holds good
return 0;
}
// error -> cannot bind rvalue reference of type 'int&&' to lvalue of type 'int'
I dont know why is it saying lvalue of type 'int' even argument is of type 'int&&'(rvalue not lvalue) help me out what's the problem. Thanks in Advance...............