Dokumentation zu: overloading(C)

HR Image


        This concept is strongly connected with the concept of inheritance.
        A function is called 'overloaded' if it is defined more than once
        in an object. This can happen if the object inherits other objects
        which have defined a function with the same name.

        Usually the overloading is wanted and intended by the inheriting
        object to change the behaviour of the function it overloads.
        To call the overloaded functions from the overloading object the
        ::-operator is used.

        From outside the object only one of the functions can be called
        via call_other() or the like; this will be the topmost of all
        overloaded functions.

        Normally an overloading function is declared the same way as the
        overloaded function, this means it has the same number and types
        of arguments. If an object wants to change the behaviour of the
        function in a way that it can get more arguments than the original
        function, it has to use the modifier 'varargs' or a compiler error
        will be raised.

        File /players/alfe/a.c:

            foo() { write("A"); }

        File /players/alfe/b.c:

            foo() { write("B"); }

        File /players/alfe/c.c:

            inherit "players/alfe/a";
            inherit "players/alfe/b";

            foo() {

        To call "players/alfe/c"->foo() will now result in the output of

        modifiers(LPC), inheritance(C), functions(LPC)

Start » Magierhandbuch » Docu » Concepts » Overloading Letzte Generierung: 25.04.2021, 01:58
Email an:
Valid HTML 4.01!