devxlogo

References

References

Question:
I want to know if the following declaration is possible:

int *p;p= new int;int &refval= *p;

Answer:
It’s valid C++. You’re binding a reference to an l-value of type int. Thus, refval becomes an alias of *p.

devx-admin

Share the Post: