Q. Which of the following correctly initializes a C++ pointer?

  • (A) int ptr = 5;
  • (B) int *ptr = &x;
  • (C) int ptr = &x;
  • (D) pointer<int> ptr;
πŸ’¬ Discuss
βœ… Correct Answer: (B) int *ptr = &x;
Explanation: In C++, a pointer is declared using an asterisk (*), and it must be initialized with the address of a variable.
Explanation by: Rakesh Kumar
In C++, a pointer is declared using an asterisk (*), and it must be initialized with the address of a variable.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
159
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Rakesh Kumar
Publisher
πŸ“ˆ
96%
Success Rate