Why does the code work when PrintIntro() method is declared above main()?

A little question about the what’s really happening when PrintIntro() is declared above the ‘main()’ method.

I understand that the code reads top-down, meaning that ‘main()’ looks for something above to call on. However I don’t understand how simply stating ‘void PrintIntro()’ with no body of code, still retrieves the full ‘PrintIntro()’ method from below ‘main()’?

There isn’t a ‘=’, so I don’t believe we are redefining PrintIntro() (unless I’m mistaken and that is exactly what is hapening), but I would have thought the full function needed to be above ‘main()’ in order for it to be called, as with '#include '.

How and why does this work?

Also, does this also work with other coding languages? I recently dd a course that introduced me to Python, and I coded a game where this would have come in very handy.

Privacy & Terms