1
4

1 回答 1

2

InterfaceImpl() returns a temporary object (rvalue) that you cannot keep in a non-const reference.

However when you instantiate IInterface i i becomes an lvalue, So you can keep it in non-const reference.

However binding non-const reference to rvalue is allowed in VS . It has been discussed in this thread

于 2013-05-18T16:05:12.047 回答