The last time I taught a course in IoT, I was able to write C++ functions after the point where they were invoked in a file. I think there was some sort of system, maybe Wiring?, that would allow that.
But now, that doesn't seem to work. I can create a .h file quickly enough, but I do miss that flexibility. What happened to it?
Using a function before implementation is a feature of the Wiring preprocessor, which is only used for .ino files, of which there can only be one per firmware application.
We recommend using a forward declaration, which is the function prototype with no body, just a semicolon before it is used, then it can be implemented later in the file.