Godot's IDE uses a high level scripting language called GDScript. Like with every other high level scripting language, your CPU doesn't execute GDScript, nor python nor any other scripting instructions, each instruction is wrapped/linked to a library that is compiled to machine code, and that one is the one that is executed, and whose values are "returned".
Therefore, you obviously can't copy paste C++ code onto Godot's IDE, since Godot doesn't have a C++ compiler+linker+assembler integrated into it.
You should follow the customs module creation guidelines found at Godot's Docs. Beware though, you will have to crosscompile this new library to every architecture you wish to run your game on, and have it included within the export templates.