0

I'm using VS2015, and I have tested in both debug and release mode, they have the same result.

int &a=1;//it's wrong, can't compile, it is what I predict to happen.
std::string &s=std::string("abc");//success to compile, looks weird to me.

As I know, you can only bind a rvalue with T&& or const T&,but not with T&. Can any one tell me why does the second line of the code can pass the compiler's check?

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
LtChang
  • 135
  • 12

0 Answers0