.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #29  
Old August 18th, 2006, 10:24 PM
PvK's Avatar

PvK PvK is offline
National Security Advisor
 
Join Date: Dec 1999
Posts: 8,806
Thanks: 54
Thanked 33 Times in 31 Posts
PvK is on a distinguished road
Default 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
Reply With Quote
 

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:21 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.