FAQ 11.07 What is the result of taking the address of a reference?

The address of a reference is the address of the referent.

Remember that the reference is the referent. Anything done to the reference including taking its address is actually done to the referent. For example, the following code will print yes since &i will be equal to &j.

 #include <iostream> using namespace std; void sample(int* p, int* q) {   if (p == q)     cout << "yes\n";   else     cout << "no\n"; } int main() {   int  i = 5;   int& j = i;   sample(&i, &j); } 


C++ FAQs
C Programming FAQs: Frequently Asked Questions
ISBN: 0201845199
EAN: 2147483647
Year: 2005
Pages: 566
Authors: Steve Summit

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net