Pointers and LValue Reference
I have this situation.
case 1
void printInt(int & i) {}
int main () {
int i=1;
printInt(&i);
}
the printInt is expecting a reference, so therefore, inside the main, I
call the printInt function and supplied with the reference i. Is this
correct.
then I can also do
case 2
int main () {
int i=1;
printInt(i); // i is a lvalue, and printInt function is
expecting a lvalue
}
so, are case 1 and case 2 seems like conflicting?
No comments:
Post a Comment