cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Pointer to const location, '&' and copy
Pointer to const location, '&' and copy CTor
Jun 24, 2011 at 8:52am UTC
ankushnandan
(64)
Hi,
is
int
foo(
int
&)
same as
int
foo(
int
*
const
)?
if yes than in case of Copy Ctor why cant we have
X(X*
const
)
instead of
X(X&)?
Jun 24, 2011 at 9:22am UTC
sohguanh
(1236)
I don't think it is the same. pointer can point to NULL at run-time whereas for reference, it always "point" to something at run-time. Usually reference variables are strongly recommended but on some occasions pointer variables is needed instead.
Topic archived. No new replies allowed.