Isn't a semicolon (';') needed after a function declaration in C++?

  • A+

I just recently took an intermediate programming test, and one of the questions I got wrong was as follows:

A semicolon (';') is not needed after a function declaration.

True or False.

I chose "false" (and please correct me if I'm wrong because I feel like I'm going crazy), a function declaration is what you write before the definition (at the top of the code) so the compiler knows the function call before even calling it, and a function definition is what makes up the function as a whole.



int func(); 


int func() {   return 1; } 

My question is, shouldn't the answer to this be false?


You can have a situation where you declare and define the function in one step, i.e. if you include the function definition at the point where you're declaring it. So technically I suppose true is correct. But the question is worded in such a way that I would have answered it the way you did.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: