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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: