Which of the following is not a correct declaration statement in C++?
2018
Which of the following is not a correct declaration statement in C++?
- A.
int *ptr=0, p;
- B.
int p, *ptr = 0;
- C.
int p; double *fp = &p;
- D.
int *p, *q, r;
Attempted by 159 students.
Show answer & explanation
Correct answer: C
In C++, pointers require matching types for valid assignment. Option C incorrectly assigns an int address to a double pointer, violating type safety rules. Options A, B, and D follow correct syntax for valid declarations.