Q:

What is the difference between a pointer and a reference in c++?

0

What is the difference between a pointer and a reference?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Answer:

A reference must always refer to some object and, therefore, must always be initialized. Pointers do not have such restrictions. A pointer can be reassigned to point to different objects while a reference always refers to an object with which it was initialized.

You can read this post “reference vs pointer“. In which I  have explained the difference between pointer and reference with the help of programming examples.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Interview Questions and Answers(2022)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
What is the virtual function?... >>
<< How to create and use a reference variable in C++?...