V
VSP
Hi,
I have a doubt regarding using references.
Please look at the below code. I am using VC++ 6.0
int &i = 10; // Compilation error
error C2440: 'initializing' : cannot convert from 'const int' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Assume that "Test" is a class
Test &t = Test(); // No compilation error
Why for built-in types assigning non-const reference with a non-lvalue is
giving error and for the
User defined type it is not giving any error?
Thanks
VSP
I have a doubt regarding using references.
Please look at the below code. I am using VC++ 6.0
int &i = 10; // Compilation error
error C2440: 'initializing' : cannot convert from 'const int' to 'int &'
A reference that is not to 'const' cannot be bound to a non-lvalue
Assume that "Test" is a class
Test &t = Test(); // No compilation error
Why for built-in types assigning non-const reference with a non-lvalue is
giving error and for the
User defined type it is not giving any error?
Thanks
VSP