• Advertisement
Sign in to follow this  

reference to a reference

This topic is 4322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

2 questions: 1. Why reference to a refrence is not allowed 2. I tried writing this code(refrence to a refrence), which compiles in VC6.0 successfully.
#include <iostream>
using namespace std;
int main()
{
int x;
int &p=x;
int &q=p;
return 0;
}

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by TEUTON
2 questions:
1. Why reference to a refrence is not allowed
Because it would be identical to a single reference.
Quote:
2. I tried writing this code(refrence to a refrence), which compiles in VC6.0 successfully.
Because initalizing a reference with a reference causes the new reference to refer to the old reference's target.

Share this post


Link to post
Share on other sites
I was going to post a new question, but it is related to this.

How can I test if two references are equal, like testing if pointers are equal?

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
How can I test if two references are equal, like testing if pointers are equal?
Just compare addresses like you would with regular objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement