LearnFrenzy
Sign in Take a free test

Functions and Default Arguments · Functions MCQ · Question 1

Function declaration vs definition in C++ Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

Which line is a function declaration but not a definition?

  • A int max(int a, int b) { return a > b ? a : b; }
  • B int max(int a, int b); Correct
  • C max(3, 4);
  • D auto m = max;
Correct Answer: Option B

A declaration ends with a semicolon instead of a body. It tells the compiler how to call the function; the definition can come later or in another file.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links