Q:

Which of the following definitions, if any, are invalid? Why?

0

Which of the following definitions, if any, are invalid? Why?

(a) int ival = 1.01;
(b) int &rval1 = 1.01;
(c) int &rval2 = ival;
(d) int &rval3;

All Answers

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

int main() {
  int ival = 1.01;  // OK
  //int &rval1 = 1.01;  // Error: initializer must be `int` object
  int &rval2 = ival;  // OK
  //int &rval3;  // Error: a reference must be initialized when defined

  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