MCQ Single Best Answer Easy

QWhat is the difference between a pointer and a reference in C++?

ID: #7196 Pointer in C Language 175 views
Question Info
#7196Q ID
EasyDifficulty
Pointer in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A A reference is a type of pointer
  • B A pointer can be reassigned to point to a different memory location, while a reference cannot
  • C A reference must be initialized when it is declared, while a pointer does not have to be
  • D A pointer is a copy of the value it points to, while a reference is an alias for the value it refers to
Correct Answer: Option B

Explanation

Answer: B

Explanation: In C++, a pointer can be reassigned to point to a different memory location, while a reference always refers to the same object throughout its lifetime. Additionally, a reference must be initialized when it is declared, while a pointer can be declared without initialization.

Share This Question

Challenge a friend or share with your study group.