csgeek
3 years ago1,000+ Views
Function Declarations in C++
Functions cannot be called before they are declared. Super important to remember. Your declaration should include all types and use the same syntax as the function definition, but you end it with a semicolon. In my example, I am doing a super simple function called sum, where I find the sum of two integers. I would declare it first as: int sum(int x, int y); And then, below main, I would write the function definition: int sum(int x, int y){ return x+y; }
3 Like
0 Share
0 comments
3
Comment
Share