dw_fluffos_v1/
dw_fluffos_v1/fluffos-1.22c11/
dw_fluffos_v1/fluffos-1.22c11/ChangeLog.old/
dw_fluffos_v1/fluffos-1.22c11/Win32/
dw_fluffos_v1/fluffos-1.22c11/compat/
dw_fluffos_v1/fluffos-1.22c11/compat/simuls/
dw_fluffos_v1/fluffos-1.22c11/include/
dw_fluffos_v1/fluffos-1.22c11/mudlib/
dw_fluffos_v1/fluffos-1.22c11/testsuite/
dw_fluffos_v1/fluffos-1.22c11/testsuite/clone/
dw_fluffos_v1/fluffos-1.22c11/testsuite/command/
dw_fluffos_v1/fluffos-1.22c11/testsuite/data/
dw_fluffos_v1/fluffos-1.22c11/testsuite/etc/
dw_fluffos_v1/fluffos-1.22c11/testsuite/include/
dw_fluffos_v1/fluffos-1.22c11/testsuite/inherit/
dw_fluffos_v1/fluffos-1.22c11/testsuite/inherit/master/
dw_fluffos_v1/fluffos-1.22c11/testsuite/log/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/compiler/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/efuns/
dw_fluffos_v1/fluffos-1.22c11/testsuite/single/tests/operators/
dw_fluffos_v1/fluffos-1.22c11/testsuite/u/
dw_fluffos_v1/fluffos-1.22c11/tmp/
dw_fluffos_v1/lib/
dw_fluffos_v1/lib/binaries/cmds/
dw_fluffos_v1/lib/binaries/cmds/creator/
dw_fluffos_v1/lib/binaries/cmds/living/
dw_fluffos_v1/lib/binaries/cmds/player/
dw_fluffos_v1/lib/binaries/d/admin/obj/
dw_fluffos_v1/lib/binaries/d/liaison/
dw_fluffos_v1/lib/binaries/global/virtual/
dw_fluffos_v1/lib/binaries/global/virtual/setup_compiler/
dw_fluffos_v1/lib/binaries/obj/handlers/autodoc/
dw_fluffos_v1/lib/binaries/obj/handlers/terrain_things/
dw_fluffos_v1/lib/binaries/obj/misc/
dw_fluffos_v1/lib/binaries/obj/misc/buckets/
dw_fluffos_v1/lib/binaries/obj/monster/
dw_fluffos_v1/lib/binaries/obj/reactions/
dw_fluffos_v1/lib/binaries/obj/reagents/
dw_fluffos_v1/lib/binaries/secure/cmds/creator/
dw_fluffos_v1/lib/binaries/secure/master/
dw_fluffos_v1/lib/binaries/std/
dw_fluffos_v1/lib/binaries/std/dom/
dw_fluffos_v1/lib/binaries/std/effects/object/
dw_fluffos_v1/lib/binaries/std/guilds/
dw_fluffos_v1/lib/binaries/std/languages/
dw_fluffos_v1/lib/binaries/std/races/
dw_fluffos_v1/lib/binaries/std/room/
dw_fluffos_v1/lib/binaries/std/room/basic/
dw_fluffos_v1/lib/binaries/std/shops/
dw_fluffos_v1/lib/binaries/std/shops/inherit/
dw_fluffos_v1/lib/binaries/www/
dw_fluffos_v1/lib/cmds/guild-race/
dw_fluffos_v1/lib/cmds/guild-race/crafts/
dw_fluffos_v1/lib/cmds/guild-race/other/
dw_fluffos_v1/lib/cmds/playtester/
dw_fluffos_v1/lib/cmds/playtester/senior/
dw_fluffos_v1/lib/d/admin/
dw_fluffos_v1/lib/d/admin/log/
dw_fluffos_v1/lib/d/admin/mapper/31-10-01/mapmaker/event/
dw_fluffos_v1/lib/d/admin/meetings/
dw_fluffos_v1/lib/d/admin/obj/
dw_fluffos_v1/lib/d/admin/room/we_care/
dw_fluffos_v1/lib/d/admin/save/
dw_fluffos_v1/lib/d/dist/
dw_fluffos_v1/lib/d/dist/mtf/
dw_fluffos_v1/lib/d/dist/pumpkin/
dw_fluffos_v1/lib/d/dist/pumpkin/chars/
dw_fluffos_v1/lib/d/dist/pumpkin/desert/
dw_fluffos_v1/lib/d/dist/pumpkin/gumboot/
dw_fluffos_v1/lib/d/dist/pumpkin/hospital/
dw_fluffos_v1/lib/d/dist/pumpkin/inherit/
dw_fluffos_v1/lib/d/dist/pumpkin/map/
dw_fluffos_v1/lib/d/dist/pumpkin/plain/
dw_fluffos_v1/lib/d/dist/pumpkin/pumpkin/
dw_fluffos_v1/lib/d/dist/pumpkin/save/
dw_fluffos_v1/lib/d/dist/pumpkin/squash/
dw_fluffos_v1/lib/d/dist/pumpkin/terrain/
dw_fluffos_v1/lib/d/dist/pumpkin/woods/
dw_fluffos_v1/lib/d/dist/start/
dw_fluffos_v1/lib/d/learning/TinyTown/buildings/
dw_fluffos_v1/lib/d/learning/TinyTown/map/
dw_fluffos_v1/lib/d/learning/TinyTown/roads/
dw_fluffos_v1/lib/d/learning/add_command/
dw_fluffos_v1/lib/d/learning/arms_and_weps/
dw_fluffos_v1/lib/d/learning/chars/
dw_fluffos_v1/lib/d/learning/cutnpaste/
dw_fluffos_v1/lib/d/learning/examples/npcs/
dw_fluffos_v1/lib/d/learning/examples/player_houses/npcs/
dw_fluffos_v1/lib/d/learning/examples/terrain_map/basic/
dw_fluffos_v1/lib/d/learning/functions/
dw_fluffos_v1/lib/d/learning/handlers/
dw_fluffos_v1/lib/d/learning/help_topics/npcs/
dw_fluffos_v1/lib/d/learning/help_topics/objects/
dw_fluffos_v1/lib/d/learning/help_topics/rcs_demo/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/crowd/
dw_fluffos_v1/lib/d/learning/help_topics/rooms/situations/
dw_fluffos_v1/lib/d/learning/items/
dw_fluffos_v1/lib/d/learning/save/
dw_fluffos_v1/lib/d/liaison/
dw_fluffos_v1/lib/d/liaison/NEWBIE/doc/
dw_fluffos_v1/lib/d/liaison/NEWBIE/save/oldlog/
dw_fluffos_v1/lib/db/
dw_fluffos_v1/lib/doc/
dw_fluffos_v1/lib/doc/creator/
dw_fluffos_v1/lib/doc/creator/autodoc/include/reaction/
dw_fluffos_v1/lib/doc/creator/autodoc/include/ritual_system/
dw_fluffos_v1/lib/doc/creator/autodoc/include/talker/
dw_fluffos_v1/lib/doc/creator/autodoc/include/terrain_map/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/baggage/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/clock/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/clothing/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/cont_save/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/corpse/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/money/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/monster/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/scabbard/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/service_provider/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/state_changer/
dw_fluffos_v1/lib/doc/creator/autodoc/obj/wand/
dw_fluffos_v1/lib/doc/creator/autodoc/std/book_dir/
dw_fluffos_v1/lib/doc/creator/autodoc/std/key/
dw_fluffos_v1/lib/doc/creator/autodoc/std/learning/
dw_fluffos_v1/lib/doc/creator/autodoc/std/map/
dw_fluffos_v1/lib/doc/creator/autodoc/std/race/
dw_fluffos_v1/lib/doc/creator/autodoc/std/weapon_logic/
dw_fluffos_v1/lib/doc/creator/files/
dw_fluffos_v1/lib/doc/creator/policy/
dw_fluffos_v1/lib/doc/creator/room/
dw_fluffos_v1/lib/doc/effects/
dw_fluffos_v1/lib/doc/ideas/
dw_fluffos_v1/lib/doc/known_command/
dw_fluffos_v1/lib/doc/lpc/basic_manual/
dw_fluffos_v1/lib/doc/lpc/intermediate/
dw_fluffos_v1/lib/doc/new/add_command/
dw_fluffos_v1/lib/doc/new/handlers/
dw_fluffos_v1/lib/doc/new/living/
dw_fluffos_v1/lib/doc/new/living/race/
dw_fluffos_v1/lib/doc/new/living/spells/
dw_fluffos_v1/lib/doc/new/player/
dw_fluffos_v1/lib/doc/new/room/guild/
dw_fluffos_v1/lib/doc/new/room/outside/
dw_fluffos_v1/lib/doc/new/room/storeroom/
dw_fluffos_v1/lib/doc/object/
dw_fluffos_v1/lib/doc/playtesters/
dw_fluffos_v1/lib/doc/policy/
dw_fluffos_v1/lib/doc/weapons/
dw_fluffos_v1/lib/global/handlers/
dw_fluffos_v1/lib/global/virtual/setup_compiler/
dw_fluffos_v1/lib/include/
dw_fluffos_v1/lib/include/cmds/
dw_fluffos_v1/lib/include/effects/
dw_fluffos_v1/lib/include/npc/
dw_fluffos_v1/lib/include/shops/
dw_fluffos_v1/lib/net/daemon/chars/
dw_fluffos_v1/lib/net/inherit/
dw_fluffos_v1/lib/net/intermud3/
dw_fluffos_v1/lib/net/intermud3/services/
dw_fluffos_v1/lib/net/obj/
dw_fluffos_v1/lib/net/save/
dw_fluffos_v1/lib/net/smnmp/
dw_fluffos_v1/lib/net/snmp/
dw_fluffos_v1/lib/obj/amulets/
dw_fluffos_v1/lib/obj/b_day/
dw_fluffos_v1/lib/obj/examples/
dw_fluffos_v1/lib/obj/food/alcohol/
dw_fluffos_v1/lib/obj/food/chocolates/
dw_fluffos_v1/lib/obj/food/fruits/
dw_fluffos_v1/lib/obj/food/meat/
dw_fluffos_v1/lib/obj/food/nuts/
dw_fluffos_v1/lib/obj/food/seafood/
dw_fluffos_v1/lib/obj/food/vegetables/
dw_fluffos_v1/lib/obj/fungi/
dw_fluffos_v1/lib/obj/furnitures/artwork/
dw_fluffos_v1/lib/obj/furnitures/bathroom/
dw_fluffos_v1/lib/obj/furnitures/beds/
dw_fluffos_v1/lib/obj/furnitures/cabinets/
dw_fluffos_v1/lib/obj/furnitures/chairs/
dw_fluffos_v1/lib/obj/furnitures/chests/
dw_fluffos_v1/lib/obj/furnitures/clocks/
dw_fluffos_v1/lib/obj/furnitures/crockery/
dw_fluffos_v1/lib/obj/furnitures/cupboards/
dw_fluffos_v1/lib/obj/furnitures/cushions/
dw_fluffos_v1/lib/obj/furnitures/fake_plants/
dw_fluffos_v1/lib/obj/furnitures/lamps/
dw_fluffos_v1/lib/obj/furnitures/mirrors/
dw_fluffos_v1/lib/obj/furnitures/outdoor/
dw_fluffos_v1/lib/obj/furnitures/safes/
dw_fluffos_v1/lib/obj/furnitures/shelves/
dw_fluffos_v1/lib/obj/furnitures/sideboards/
dw_fluffos_v1/lib/obj/furnitures/sofas/
dw_fluffos_v1/lib/obj/furnitures/stoves/
dw_fluffos_v1/lib/obj/furnitures/tables/
dw_fluffos_v1/lib/obj/furnitures/wardrobes/
dw_fluffos_v1/lib/obj/handlers/
dw_fluffos_v1/lib/obj/handlers/autodoc/
dw_fluffos_v1/lib/obj/jewellery/anklets/
dw_fluffos_v1/lib/obj/jewellery/bracelets/
dw_fluffos_v1/lib/obj/jewellery/earrings/
dw_fluffos_v1/lib/obj/jewellery/misc/
dw_fluffos_v1/lib/obj/jewellery/necklaces/
dw_fluffos_v1/lib/obj/jewellery/rings/
dw_fluffos_v1/lib/obj/media/
dw_fluffos_v1/lib/obj/misc/buckets/
dw_fluffos_v1/lib/obj/misc/jars/
dw_fluffos_v1/lib/obj/misc/papers/
dw_fluffos_v1/lib/obj/misc/player_shop/
dw_fluffos_v1/lib/obj/misc/shops/
dw_fluffos_v1/lib/obj/misc/traps/
dw_fluffos_v1/lib/obj/monster/
dw_fluffos_v1/lib/obj/monster/godmother/
dw_fluffos_v1/lib/obj/monster/transport/
dw_fluffos_v1/lib/obj/plants/inherit/
dw_fluffos_v1/lib/obj/potions/
dw_fluffos_v1/lib/open/boards/
dw_fluffos_v1/lib/save/autodoc/
dw_fluffos_v1/lib/save/bank_accounts/
dw_fluffos_v1/lib/save/boards/frog/
dw_fluffos_v1/lib/save/books/bed_catalog/
dw_fluffos_v1/lib/save/creators/
dw_fluffos_v1/lib/save/mail/
dw_fluffos_v1/lib/save/mail/p/
dw_fluffos_v1/lib/save/newsrc/b/
dw_fluffos_v1/lib/save/newsrc/c/
dw_fluffos_v1/lib/save/newsrc/d/
dw_fluffos_v1/lib/save/newsrc/f/
dw_fluffos_v1/lib/save/newsrc/p/
dw_fluffos_v1/lib/save/newsrc/s/
dw_fluffos_v1/lib/save/newsrc/w/
dw_fluffos_v1/lib/save/players/c/
dw_fluffos_v1/lib/save/players/d/
dw_fluffos_v1/lib/save/players/g/
dw_fluffos_v1/lib/save/players/p/
dw_fluffos_v1/lib/save/players/s/
dw_fluffos_v1/lib/save/soul/data/
dw_fluffos_v1/lib/save/tasks/
dw_fluffos_v1/lib/save/vaults/
dw_fluffos_v1/lib/secure/cmds/lord/
dw_fluffos_v1/lib/secure/config/
dw_fluffos_v1/lib/secure/items/
dw_fluffos_v1/lib/secure/player/
dw_fluffos_v1/lib/soul/
dw_fluffos_v1/lib/soul/i/
dw_fluffos_v1/lib/soul/j/
dw_fluffos_v1/lib/soul/k/
dw_fluffos_v1/lib/soul/o/
dw_fluffos_v1/lib/soul/q/
dw_fluffos_v1/lib/soul/to_approve/
dw_fluffos_v1/lib/soul/u/
dw_fluffos_v1/lib/soul/v/
dw_fluffos_v1/lib/soul/wish_list/
dw_fluffos_v1/lib/soul/y/
dw_fluffos_v1/lib/soul/z/
dw_fluffos_v1/lib/std/creator/
dw_fluffos_v1/lib/std/effects/
dw_fluffos_v1/lib/std/effects/attached/
dw_fluffos_v1/lib/std/effects/external/
dw_fluffos_v1/lib/std/effects/fighting/
dw_fluffos_v1/lib/std/effects/other/
dw_fluffos_v1/lib/std/environ/
dw_fluffos_v1/lib/std/guilds/
dw_fluffos_v1/lib/std/hospital/
dw_fluffos_v1/lib/std/house/
dw_fluffos_v1/lib/std/house/onebedhouse/
dw_fluffos_v1/lib/std/house/onebedhut/
dw_fluffos_v1/lib/std/house/tworoomflat/
dw_fluffos_v1/lib/std/languages/
dw_fluffos_v1/lib/std/liquids/
dw_fluffos_v1/lib/std/nationality/
dw_fluffos_v1/lib/std/nationality/accents/
dw_fluffos_v1/lib/std/nationality/accents/national/
dw_fluffos_v1/lib/std/nationality/accents/regional/
dw_fluffos_v1/lib/std/npc/goals/
dw_fluffos_v1/lib/std/npc/goals/basic/
dw_fluffos_v1/lib/std/npc/goals/misc/
dw_fluffos_v1/lib/std/npc/inherit/
dw_fluffos_v1/lib/std/npc/plans/
dw_fluffos_v1/lib/std/npc/plans/basic/
dw_fluffos_v1/lib/std/outsides/
dw_fluffos_v1/lib/std/races/shadows/
dw_fluffos_v1/lib/std/room/basic/topography/
dw_fluffos_v1/lib/std/room/controller/
dw_fluffos_v1/lib/std/room/controller/topography/
dw_fluffos_v1/lib/std/room/furniture/games/
dw_fluffos_v1/lib/std/room/furniture/inherit/
dw_fluffos_v1/lib/std/room/inherit/carriage/
dw_fluffos_v1/lib/std/room/inherit/topography/
dw_fluffos_v1/lib/std/room/punishments/
dw_fluffos_v1/lib/std/room/topography/area/
dw_fluffos_v1/lib/std/room/topography/iroom/
dw_fluffos_v1/lib/std/room/topography/milestone/
dw_fluffos_v1/lib/std/shadows/
dw_fluffos_v1/lib/std/shadows/attached/
dw_fluffos_v1/lib/std/shadows/curses/
dw_fluffos_v1/lib/std/shadows/disease/
dw_fluffos_v1/lib/std/shadows/fighting/
dw_fluffos_v1/lib/std/shadows/room/
dw_fluffos_v1/lib/std/shops/controllers/
dw_fluffos_v1/lib/std/shops/objs/
dw_fluffos_v1/lib/std/shops/player_shop/
dw_fluffos_v1/lib/std/shops/player_shop/office_code/
dw_fluffos_v1/lib/std/socket/
dw_fluffos_v1/lib/www/
dw_fluffos_v1/lib/www/external/autodoc/
dw_fluffos_v1/lib/www/external/java/telnet/Documentation/
dw_fluffos_v1/lib/www/external/java/telnet/Documentation/images/
dw_fluffos_v1/lib/www/external/java/telnet/examples/
dw_fluffos_v1/lib/www/external/java/telnet/tools/
dw_fluffos_v1/lib/www/pics/
dw_fluffos_v1/lib/www/secure/creator/
dw_fluffos_v1/lib/www/secure/editors/
dw_fluffos_v1/lib/www/secure/survey_results/
<html><!-- #BeginTemplate "/Templates/Body Text.dwt" -->
<head>
<title> Discworld Documentation </title>
</head>
<body bgcolor="#ffffff" TEXT="#000030" LINK="#4a529c" VLINK="#b57339">
<table width="75%" border="0">
  <tr>
    <td><font face="arial,helvetica"><img align=left src="http://discworld.imaginary.com/external//pics/dw4.gif"></font></td>
    <td><font face="arial,helvetica">
      <h2>Discworld Documentation:</h2>
      <h2>LPC for Dummies</h2>
      </font> 
      <p><font size="+1"><!-- #BeginEditable "Title" --><font size="+1"><b>Chapter Four: 
  Inheritance</b></font><!-- #EndEditable --></font></p>
      <p><i>N.B - This is a work in progress... a living document if you like. 
        If it appears to be dead when you view it, don't worry. It's most likely 
        just playing possum.</i></p>
      <p>Comments on these chapters and tutorials can be e-mailed to <a href="mailto:drakkos@cableinet.co.uk">Drakkos.</a></p>
    </td>
  </tr>
</table>
<br>
<!-- #BeginEditable "Body" --> 
<p>The basic concept behind inheritance is simple. Say you have an object that 
  you want to work as a weapon. In order to do so, you need to code a certain 
  amount of functionality into the object. You need to code it so it can be wielded... 
  so that it can be aimed at someone, and so that it can do damage to the target. 
  You might also want to code it so that it can get damaged during a fight, or 
  so that it's particularly effective against one type of armour, but not against 
  another. Obviously a whole lot of effort has to go in to creating the weapon... 
  and this code has to be duplicated and modified every time you want to create 
  another weapon. </p>
<p>Eventually, you find out that another creator has been coding weapons as well, 
  that work almost the same way as yours do... but not exactly, so they are incompatible. 
  You have discontinuities such as one type of weapon breaking in combat, while 
  another doesn't even take damage. This is undesirable, and leads to a patchwork, 
  unprofessional MUD. </p>
<p>A much better solution is to have one piece of code that defines the behaviour 
  and logic of a particular object, and allow other objects to use that as a base, 
  modifying the base code as necessary to produce unique objects. This is done 
  using a method called 'inheritance'. </p>
<p>The term derives from the natural world... an example of the principle in practise 
  is shown below:</p>
<blockquote> 
  <blockquote> 
    <blockquote> 
      <blockquote>
        <pre>                    Animal
                    /    \
                   /      \
                Mammal   Reptile
                /   \     
               /     \
             Dog     Cat 
             /
            /
        Great Dane        </pre>
      </blockquote>
    </blockquote>
  </blockquote>
</blockquote>
<p>All animals have a certain number of characteristics that are common to all. 
  They all require sustenance to survive... they are all capable of procreation, 
  and they all have a limited life span. </p>
<p>However, there are differences between mammals and reptiles. Reptiles are cold 
  blooded, for example, and mammals are warm blooded. Both 'inherit' the properties 
  of being an animal, but refine it slightly more.</p>
<p> Likewise, dogs and cats have their differences too... but each inherits the 
  basic properties of being a mammal... and so also inherit the properties of 
  being an animal. Great Danes inherit all the properties of being a dog, and 
  so all the properties of being a mammal, and so all the properties of being 
  an animal.</p>
<p> <b>Object Orientated Programming </b></p>
<p>This model can be applied successfully to computer programming to provide a 
  basic library of functionality for objects, and allow other objects to 'inherit' 
  this functionality, as well as providing their own. This ensures compatibility 
  without stifling creativity, and so is a Very Good Thing. </p>
<p>Let's have a look at how this technique would work in practise. Let's say we 
  have two objects. An object called bing, and an object called bong. Bing has 
  the functions 'frog' and 'womble' defined. Bong has the function 'wibble' defined:</p>
<blockquote> 
  <p> <code>bong.c:</code></p>
  <blockquote> 
    <p><code> void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
  </blockquote>
  <p><code> bing.c:</code></p>
  <blockquote> 
    <p><code> void frog() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Frog!\n");<br>
      }<br>
      <br>
      void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Womble!\n"); <br>
      }</code></p>
  </blockquote>
</blockquote>
<p> Now, if we call the function frog() in the object bong, we'll get an error 
  stating the function is not defined. However, if we called wibble(), we get 
  the text "Wibble!" printed to the screen. Likewise, calling wibble in bing will 
  give a function not defined error, whereas both frog() and womble() will print 
  the relevant text.</p>
<p> If we weren't using inheritance, in order include the functions frog() and 
  womble() into object bong, it would be necessary to duplicate the code into 
  bong like so: </p>
<blockquote> 
  <p><code>bong.c: </code></p>
  <blockquote> 
    <p><code>void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
    <p><code>void frog() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Frog!\n");<br>
      }</code></p>
    <p><code>void womble() { <br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Womble!\n");<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> If we then wanted to change the function frog() to print out "frog frog!", 
  we'd need to alter the code in both object bing and in object bong. Imagine 
  if these were useful functions that were spread over a thousand pieces of code 
  over the MUD. Nightmare!</p>
<p> However, if it were possible to 'inherit' the properties of object bing, it 
  would be possible to then use the functions in bong as if they had been duplicated: 
</p>
<blockquote> 
  <p><code>bong.c </code></p>
  <blockquote> 
    <p><code>inherit "bing";</code></p>
    <p><code> void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> So, in our new object bong, we can now call the methods frog() and womble() 
  in addition to wibble(). Neat! But why is this better than duplicating the code 
  each time? Well, there are a number of reasons:</p>
<p> 1) Storing the code in an object that is then inherited means that wide ranging 
  changes to functionality can be made only by changing the object that is inherited. 
  Instead of having to change frog() in every object that has the function, we 
  simply change it in bing, and every object that inherits the function will be 
  changed. </p>
<p>2) Providing substantially usable objects as a basis to be inherited allows 
  for greater consistency and efficiency when creating. You don't need to reinvent 
  the wheel for every object. So instead of adding code to hold, wield, and break 
  weapons, you simply inherit a single file that does all that for you. This leaves 
  you to be more creative without worrying about the low level functionality.</p>
<p> 3) It is much more efficient with regards to the driver. Briefly, rather than 
  compiling each duplicated function separately in each object, inheritance allows 
  for objects to share the same piece of compiled code. Each object will have 
  individual copies of each global variable within the object, however: this means 
  that if objects A and B inherit object C, the running of object A will not interfere 
  in any way with the running of object B because they both have their own slice 
  of memory containing their various variables.</p>
<p> <b>Masking Inherited Methods</b></p>
<p> Of course, in many cases an object that you inherit may provide a function 
  that you would like to utilise... unfortunately, this object does not provide 
  quite the functionality that you require for your object. Perhaps you need to 
  do an extra check on a particular variable, for example, but the inherited function 
  does not do this. Fear not! You are not stumped because of this, because it 
  is possible to 'mask' inherited methods to change the functionality! </p>
<p>Let us look back to our object bong. Let's say we want to inherit bing as above, 
  but rather than print "Womble!" when we call the function womble(), we want 
  it to print out "Uncle Bulgaria!" instead.</p>
<p> The code for printing "Womble" is already in place. What we want to do, however, 
  is redefine this method locally in bong so that it prints out "Uncle Bulgaria". 
  But, since we want to keep the functionality of the frog() function, we don't 
  want to simply write an object that does not inherit bing. Instead, we override, 
  or mask, the womble method to:</p>
<blockquote> 
  <p> <code>bong.c</code></p>
  <blockquote> 
    <p><code> inherit "bing";</code></p>
    <p><code> void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
    <p><code> void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Uncle Bulgaria!\n");<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> Now, when the function womble() is called on bong, we get the text 'Uncle 
  Bulgaria!' instead of the text 'Womble!'. Neat! But what if we wanted to print 
  out "Uncle Bulgaria!" first, then the text "Womble!" in the inherited method? 
  Well, we could do this by duplicating the code from bing... but that's not compatible 
  with our inheritance model. Instead, we can 'override' a method to first perform 
  some code in our local object before executing the code in the inherited object. 
  We do this using the '::' scope definition to preface the name of the function. 
  This essentially states 'go back one object in the inheritance chain and try 
  to call this function'. If that function doesn't exist, it will continue to 
  travel down the inheritance chain until it finds an object that does define 
  it, or throws out an error because the function doesn't exist anywhere: </p>
<blockquote> 
  <p><code>bong.c </code></p>
  <blockquote> 
    <p><code>inherit "bing";</code></p>
    <p><code> void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
    <p><code> void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Uncle Bulgaria!\n");<br>
      &nbsp;&nbsp;&nbsp;&nbsp;::womble();</code></p>
    <p><code> }</code></p>
  </blockquote>
</blockquote>
<p> Now calling the function womble in bong will produce: </p>
<blockquote> 
  <p><code>Uncle Bulgaria!<br>
    Womble!</code></p>
</blockquote>
<p> If we wanted it the other way around, we could do:</p>
<blockquote> 
  <p> <code>bong.c</code></p>
  <blockquote> 
    <p><code> inherit "bing";</code></p>
    <p><code> void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
    <p><code> void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;::womble();<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Uncle Bulgaria!\n");<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> Which would print:</p>
<blockquote> 
  <p> <code>Womble!<br>
    Uncle Bulgaria!</code></p>
</blockquote>
<p> This is only a very simple example of how we can use these techniques, of 
  course. In day to day creatoring, it is likely you will be inheriting objects 
  that inherit other objects that inherit multiple objects in the same file! At 
  this time, however, you do not need to think too deeply about any of this.</p>
<p> <b>Variable and Function Qualifiers</b></p>
<p> But wait, there's more! Of course there's more! Sometimes in objects, you 
  will notice the functions and variables may be prefaced with Unusual and Arcane 
  words. 'private', 'public', 'protected'. Although related primarily to functions 
  and variables, we couldn't cover them in those chapters because it is necessary 
  to understand the basics of inheritance before some of them make sense. Having 
  read what we have above, hopefully you will have the appreciation of inheritance 
  required to be able to fully understand what these 'qualifiers' do. </p>
<p>Occasionally, for security reasons, it will be necessary for a variable or 
  function to be made invisible to an object that inherits it. For example, if 
  we have a variable called 'name' used in the inheritable, we don't want any 
  objects that inherit it to later over-write the value of this because of a locally 
  defined variable or function. The 'private' qualified exists for this reason, 
  and is used thusly:</p>
<blockquote> 
  <p> <code>private string _name;</code></p>
  <p><code> private void my_function () {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;printf("Wheee!\n");<br>
    }</code></p>
</blockquote>
<p> Private variables and functions may only be referenced in the object that 
  defines them... they cannot be referenced in any object that may inherit them. 
  Let's look back on our bing inheritable, and add in two new methods:</p>
<blockquote> 
  <p> <code>bing.c:</code></p>
  <blockquote> 
    <p><code> void frog() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Frog!\n");<br>
      }</code></p>
    <p><code> void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Womble!\n");<br>
      }</code></p>
    <p><code><br>
      void wobble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;do_print_message();<br>
      }</code></p>
    <p><code> private void do_print_message() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wobble!\n");<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> Again, we will say that object bong inherits object bing. Now, say we want 
  to call the wobble() function in bong. We do so, and the text:</p>
<blockquote> 
  <p> <code>Wobble!</code></p>
</blockquote>
<p> Appears on our screen as can be expected. All well and good, but all wobble() 
  does is call another function that prints the message. But if we try and call 
  this function directly from bong, we get an error message stating the function 
  does not exist.</p>
<p> The reasons this will generally be done are for security and to ensure data 
  integrity. Unless you are actually going to dabble in writing inheritables (and 
  that is beyond the scope of this document), you will only need to know what 
  the private qualifier implies.</p>
<p> Another qualifier you are likely to see is the qualifier 'nomask'. A function 
  qualified as 'nomask' cannot be masked or overridden as defined above... it 
  will only give an error when you attempt to do so. For example, let's say we 
  change our object bing a little:</p>
<blockquote> 
  <p> <code>bing.c:</code></p>
  <blockquote> 
    <p><code> void frog() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Frog!\n");<br>
      }</code></p>
    <p><code>nomask void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;do_print_message();<br>
      }</code></p>
    <p><code> private void do_print_message() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Womble!\n");<br>
      } </code></p>
  </blockquote>
</blockquote>
<p>And we leave bong exactly as it was:</p>
<blockquote> 
  <p> <code>bong.c </code></p>
  <blockquote> 
    <p><code>inherit "bing"; </code></p>
    <p><code>void wibble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Wibble!\n");<br>
      }</code></p>
    <p><code> void womble() {<br>
      &nbsp;&nbsp;&nbsp;&nbsp;printf("Uncle Bulgaria!\n");<br>
      &nbsp;&nbsp;&nbsp;&nbsp;::womble();<br>
      }</code></p>
  </blockquote>
</blockquote>
<p> This will now produce a parse error when you attempt to compile bong. This 
  is because our object attempts to redefine the function womble(), which we just 
  qualified as 'nomask'. Like with private qualifier, this is usually done for 
  security, so that critical functions cannot be masked to return false values 
  for the purpose of circumventing code that depends on it. </p>
<p>Sometimes a function or a variable will be qualified as 'public'. This is the 
  default for functions and variables, and can be assumed when no qualifier is 
  present. It means that a function/variable is available to all objects that 
  inherit it, and can be masked/overridden as defined above. </p>
<p>Although it is not directly related to inheritance, there is another function 
  qualifier called 'varargs' that can be used to change the way a function deals 
  with arguments being passed in. Normally when you define a list of parameters 
  to a function, you will get a parse error if you try and pass in a different 
  number when you call the function. It is possible to qualify a function as varargs, 
  however, which will allow you to be somewhat more flexible with the function. 
  You cannot pass in more arguments than you previously specify, but you can pass 
  in a smaller number, with the remainder being passed in as 0: </p>
<blockquote> 
  <p><code>varargs void test_function (string, string, int);</code></p>
  <p><code> test_function (string name, string word, int value) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;printf("Arguments are: %s, %s, %d\n", name, word, 
    value);<br>
    }</code></p>
</blockquote>
<p> By declaring our test_function as varargs, we can call it with anything between 
  zero and three arguments. You will need to manually design your function so 
  that it behaves differently depending on what is passed in, however... varargs 
  cannot do this for you.</p>
<p> Let's look at what is passed in with three different argument lists to the 
  test_function: test_function("drakkos"), test_function("Drakkos", "bing!"), 
  and test_function("Drakkos, "bing!", 10). The printf in our function will print 
  the argument list in order, so let's see what the printf will come up with:</p>
<blockquote> 
  <p> <code>test_function("drakkos"):<br>
    Arguments are: drakkos, 0, 0 </code></p>
  <p><code>test_function("drakkos", "bing!"):<br>
    Arguments are: drakkos, bing!, 0 </code></p>
  <p><code>test_function("drakkos", "bing!", 10):<br>
    Arguments are: drakkos, bing!, 10</code></p>
</blockquote>
<p> This is an extremely useful qualifier when writing generic inheritables... 
  in general you will not have to use this qualifier, but as always, it is important 
  to understand what it does. </p>
<p><b>Chapter Summary</b></p>
<p> In this chapter, we discussed the basics of inheritance, and how it can be 
  used to improve quality and consistence within the MUD. We also looked at how 
  to redefine methods, and how to qualify our functions so as to alter their behaviour 
  in regards to other objects that inherit them. </p>
<ul>
  <li><code>One of the key benefits of inheritance is that it allows for greater 
    efficiency and object reusability.</code></li>
  <li><code> Inheritables are inherited using the inherit keyword, followed by 
    the path of the file to inherit: inherit "/obj/monster"; </code></li>
  <li><code>Objects that inherit other objects can access the functions in the 
    inherited object as if they were defined locally.</code></li>
  <li><code> Objects that inherit other objects get their own memory allocated 
    for global variables, although they use the same compiled function code.</code></li>
  <li><code> Inherited functions can be redefined, or masked, locally to alter 
    their behaviour. The :: scope operator can be used to call functions in inherited 
    objects.</code></li>
  <li><code> Variables and functions can be 'qualified' using qualifier keywords.</code></li>
  <li><code> The private qualifier makes a function or variable invisible to any 
    object that inherits it.</code></li>
  <li><code> The nomask qualifier makes it impossible to redefine the qualified 
    # function locally.</code></li>
  <li><code> The varargs qualifier can be used to make argument lists more flexible 
    by allowing variable numbers of arguments to be passed in as a function. Arguments 
    that are not explicitly passed in will be treated as if they were 0.</code></li>
</ul>
<!-- #EndEditable --> 
<p>
<hr>
<center><font size="-1"><a href="/login.html">Discworld MUD</a>'s world wide web pages.<br>brought to you by<br>
  <strong>Cut Me Own Throat Dibbler's <a href="/sausages.html">Sensational Sausages</a>;&nbsp;buy 
  one while they are hot.</strong> <br>
<hr>Lost?  Try Discworld's <a href="/">home page</a>.</font></center><font size="-1"><i><a href="mailto:drakkos@cableinet.co.uk"><font size="-2">Mail Drakkos!</font></a></i>
</font>
</body>
<!-- #EndTemplate --></html>