int howBig = 200; int &rIntRef = howBig;
ok, that's easy and straightforward. But then I am confused when a reference is being used in a program. there's no single two statements that look like that in the reference. Here's the code:
void swap(int &rt, int &ry, int &rz)
{
int temp;
std::cout << "Swap. before swap, rt: " << rt << " ry " << ry << " rz: " << rz << "\n";
temp = rt;
rt = ry;
ry = rz;
rz = temp;
std::cout << "swap. after swap, rt: " << rt << " ry: " << ry << " rz: " << rz << "\n";
}
this code is part of a larger program that compiled and ran just fine. But I don't understand how the reference is being initialized. For example, the declaration around void swap(int &rt...). is this the declaration?
int &rt; int temp; temp = rt;
if so, then when commented out the temp = rt; line, the compiler should have flagged that as an error. but it didn't. so now i don't know what's being referenced. Thanks for any clarification.

New Topic/Question
Reply



MultiQuote


|