Global function
Global function - a function seen from anywhere in the program (as opposed to a local function that can be called - visibility is limited to a module or class).
Overuse of global functions can lead to serious problems such as littering of namespaces. In modern programming languages like C # there is a tendency to abandon both global functions and global variables by enclosing them in classes that can be global. Creating functions as well as global variables is a bad programming practice. So, to simulate a global function, you should use a class with a static method. Example in C ++: class MojeFunkcje { public: static char fun1 () {/ * instructions * /} static int fun2 () {/ * instructions * /} static void fun3 () {/ * instructions * /} // other functions }; The member functions of the MyFunction class are marked as static. It is not necessary to have an object of the MyFunction class. Thus, one can refer to each of them by preceding it with a range operator: eg Functions: fun3 (); A similar technique applies to global variables.
wiki
Comments
Post a Comment