Re: OT: Stupid c++
I don't really know what you're doing, so NarfClass was just an example. NarfClass would be any class that wants to be able to use some external object, without requiring the external object to actually be defined as a global with a certain name in the class definition.
Actually, the classic approach to doing what I think you probably really want to do is to make the Character Vector into a singleton class - a class designed to ensure there is only one of something, and provide access to it to other classes.
I don't really know what your class design is like - that is, how you've decided to divide up the things in your game into classes.
extern is a keyword for referring to objects or variables defined in other files, which would be how you can refer to globals created in other files. The syntax is, for example:
extern int X9B;
This lets you use X9B, but in one and only one other file you need to have the actual declaration:
int X9B;
So you can see that can make your code hard to read and use the more you do that, because it means you have to remember where that global is actually defined, etc.
PvK
|