I’ve got several classes of game object that are all descended from one basic class. I want each class to maintain its own static Hashtable, which will contain
every initialized instance of that class.
To this end, I declare a private static Hashtable objectTable in each class, and init them, in each class, in a static block.
Trouble is, all my classes always end up accessing the table for that basic class whenever I try to iaccess the table directly (ie - objectTable.put(…) or something). I’ve developed a very ugly workaround, wherein I place the exact same method:
Hashtable getObjectTable() {return objectTable;}
in every subclass, and always use getObjectTable().put(…) instead of just objectTable.put(…). Now the correct static table is always used. Why is this necessary? Am I doing something wrong or is this just how static hiding works? Thanks all,
Bret