| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
A "Global" problem
Hey everyone,
I'm trying to create a small engine for creating a game with and I'm running into a problem with my global variables (sort of). I have global pointers to classes I've created. So far, I have one for the system and one for the window object. I had initially just put them in the top of main, but I decided that wasn't best. I put them in a (.cpp) file for global variables and pointers and, since I had a derived class, I put the derived class in the accompanying (.h) file. I couldn't get to these global pointers in main, but I fixed that with extern. That was easy enough. What I really have a problem with is the derived class. I have included the file with the base class in it in the global.h file, but the compiler claims that the base class is undefined. Some of the code: Code:
//sGlobals.h - Global handles to objects
#pragma once
#include "sWindow.h"
class CustomWin : public sWindow
{
public:
CustomWin(void) {};
~CustomWin(void) {};
bool Frame(void) {return true;};
};
Am I doing something wrong here? Any help is greatly appreciated. |
|
#2
|
|||
|
|||
|
I personally keep base class declarations and derived class declarations in the same .h file. This just makes it easier to find. As for your problem, I have no way of knowing what it is without looking at the "sWindow.h" file and maybe even the .cpp files. Come to think of it shouldn't you be including the "sGlobal.h" and not the "sWindows.h" or both.You said you declared the base class inside the globals file.
|
|
#3
|
|||
|
|||
|
Sorry, I do realize now that some of the ways I worded some things was confusing. What I meant is that I used the #include keyword to include the file sWindow.h in Globals.h, not that the base class was in Globals.h.
However, your suggestion to move the derived class into the same header the base class was in worked perfectly. Thank you very much! ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > A "Global" problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|