没找到具体原因,MSDN看到下面这句,VC是从2008才有这一限制的,感觉就是从语法上对临时变量增加了限定,因为一般说来修改一个临时变量是毫无意义的,通过增加限定,强调临时变量只读语义。虽然实际上修改临时变量并不会有问题。

Visual Studio 2008

In previous releases of Visual C++, non-const references could be bound to temporary objects. Now, temporary objects can only be bound to const references.

相关文章:

  • 2022-01-09
  • 2022-12-23
  • 2022-01-23
  • 2021-11-27
  • 2021-12-29
  • 2021-06-03
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-11
  • 2021-06-06
  • 2022-12-23
相关资源
相似解决方案