aliens

Author Topic: Question about OpenXcom namespace  (Read 967 times)

Offline Skybuck

  • Colonel
  • ****
  • Posts: 223
    • View Profile
Question about OpenXcom namespace
« on: March 31, 2022, 12:27:43 pm »
BattlescapeGame.h contains:

namespace OpenXcom
{

class BattleUnit;
class SavedBattleGame;
class BattleItem;
class BattleState;
class BattlescapeState;
class Map;
class TileEngine;
class Pathfinding;
class Mod;
class InfoboxOKState;
class SoldierDiary;

I am not familiar with this.

To me they seem like some kind of forward declaration or perhaps some kind of indicator that it's ok to use these ?

What does this do in C++ ?

It seems to be some kind of forward declaration, so this then leads to the question:

Why not simply include those classes/header files ?

Could this be because of circular reference/header inclusion ?

Or is there some other technical reason for this ?

Maybe to make this BattlescapeGame a "master" class which can be referenced to by others for accessing a whole bunch of stuff or saving/loading games files ?!

Maybe for convenience, central class to access other data, and group data together...  (?)
« Last Edit: March 31, 2022, 12:31:44 pm by Skybuck »

Offline Yankes

  • Commander
  • *****
  • Posts: 3210
    • View Profile
Re: Question about OpenXcom namespace
« Reply #1 on: March 31, 2022, 12:51:44 pm »

To me they seem like some kind of forward declaration or perhaps some kind of indicator that it's ok to use these ?
This IS forward declaration. This inform C++ that type like this exists but you can't use it fully yet. You need have definition available to use given type.