Importance of the function name (main)?

I was playing around with the exercise and was referencing the “DoubleMe” slide. If I put any other text other than “main” I received errors about making a wrong reference. Why is that? Does the code specifically reference main.cpp? I find that confusing since we’re editing code under main.cpp.

As far as functions go, Main() cannot be changed. unlike other functions that we as programmers usually call, Main() is called by the operating system. It will look for and call it by that specific name, so if its changed it wont find it and the program won’t start. Hope that was what you were referring to.

1 Like

Thanks! That definitely helps clear things up. So my last question about that then would be that in this particular case is the Main() separate from the main.cpp?

int main() is a function, main.cpp is the file. You could technically call the file anything, but the main function has to be somewhere in your project files, which is typically in the file main.cpp.

2 Likes