C++ MQCs with Explanation (CHAPTER : POINTERS, VIRTUAL FUNCTIONS AND POLYMORPHISM )

Identy the error in the following code segment int *ptr, m = 100; // line 1 cout << *ptr; //line 2

  1. Declaring ptr and m in one line is wrong
  2. In line 2, *ptr should be written as &ptr
  3. The address of m should be assigned to ptr before it is accessed
  4. No error



Answer: 
Option c: The address of m should be assigned to ptr before it is accessed

Explanation Here

Post a Comment

0 Comments