G
Guest
Hi, folks,
Look at the following snippet:
int main()
{
double temp = 2.0;
const double& r = 2.0 + temp; // without const, an err will be
raised
return 0;
}
As the comment block illustrated, without "const" qualifier
error: could not convert `(temp + 2.0e+0)' to `double&'
will be raised, I know, you can't use an expression to initialize a
reference, but why it's OK with const qualifier? Thanks, you guys.
Look at the following snippet:
int main()
{
double temp = 2.0;
const double& r = 2.0 + temp; // without const, an err will be
raised
return 0;
}
As the comment block illustrated, without "const" qualifier
error: could not convert `(temp + 2.0e+0)' to `double&'
will be raised, I know, you can't use an expression to initialize a
reference, but why it's OK with const qualifier? Thanks, you guys.