The code:
class ra{
public:
};
ra hey(){
ra io;
return io;
}
void e(ra& i){
std::cout << "on" << std::endl;
}
int main() {
e(hey());
}
Why does that compile? shouldn't the call to ra in main,return a temporary object,which is a const,an rvalue? So e shouldn't accept it,because it's a const!
Why does the above code work?