Trying to learn c++ and read the functions guide on c++ tutorials here on this site. I wondered, why do you have to use parenthesis after the printmessage in the bracket of the main function.
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
void printmessage ()
{
cout << "I'm a function!";
}
int main ()
{
printmessage ();
}
That's just the way C++ denotes a function, very common for many languages, not to mention for mathematics itself ( like f(x, y) ). It's relatively easy to parse because you know it has to be a function if it's a delimiting set of parentheses after a name.
Also, if your function actually had arguments that were passed into it, then that's where those arguments would go. ex: abs(-3)
If you want to get more technical, the name of the function itself is a pointer to the function, just as the name of an array is the pointer to that array. Don't worry about that if you haven't learned about pointers yet.