Q:

Explain the following definitions. Identify any that are illegal

0

Explain the following definitions. Identify any that are illegal.

(a) int i, *const cp;
(b) int *p1, *const p2;
(c) const int ic, &r = ic;
(d) const int *const p3;
(e) const int *p;

All Answers

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

#include <iostream>

int main() {
  //(a)
  //int i, *const cp;  // Error: a const pointer must be initialized
  //(b)
  //int *p1, *const p2;  // Error: a const pointer must be initialized
  //(c)
  //const int ic, &r = ic;  // Error: const int `ic` must be initialized
  //(d)
  //const int *const p3;  // Error: a const pointer must be initialized
  //(e)
  const int *p;  // OK

  return 0;
}

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

total answers (1)

Similar questions


need a help?


find thousands of online teachers now