Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Example
For example, the following sample has different run-time behavior in Visual Studio .NET 2003 compared to Visual Studio .NET:
// bc_temp_objects_not_bound_to_nonconst_ref.cpp
// compile with: /EHsc
#include "iostream"
using namespace std;
class C {};
void f(C & c) { cout << "C&" << endl; }
void f(C const & c) { cout << "C const &" << endl; }
int main() {
f(C());
}
C const &