![]() |
| | #1 |
| Registered User Join Date: Apr 2008
Posts: 58
| Class read as variable, default-type int? Say what?! The header class provided below will not read the "ApplicationManager" class properly. Code: #ifndef _GAME_H_
#define _GAME_H_
#include "application.h"
#include "applicationmanager.h"
class Game : public Application
{
public:
Game();
~Game();
void LoadContent() override;
void UnloadContent() override;
void Draw() override;
private:
//int ApplicationManager; //WHY DOES THIS COMPILE??!
ApplicationManager management; //This DOES NOT WORK?
};
#endif
Here is the header for the "ApplicationManager" class. Code: #ifndef _APPMANAGER_H_
#define _APPMANAGER_H_
#include "game.h"
#include "application.h"
class ApplicationManager
{
public:
ApplicationManager(void);
~ApplicationManager(void);
private:
};
#endif
The error that occurs, tells me that I need a ";" before "management", and that "ApplicationManager" is missing a type specifier, so it is assumed to be default-type int. ...any ideas why it won't compile properly? Can someone else try this and report the results? I copied the code, and pasted it in a different solution, to see if something became corrupted....it still didn't work. |
| arcaine01 is offline | |
| | #2 |
| Banned Join Date: Mar 2009
Posts: 533
| you need to tell it what ApplicationManager is before you can make one
__________________ ╔╗╔══╦╗ ║║║╔╗║║ ║╚╣╚╝║╚╗ ╚═╩══╩═╝ |
| ಠ_ಠ is offline | |
| | #3 |
| Registered User Join Date: Apr 2008
Posts: 58
| I'm a little confused about what you are instructing me to do. ApplicationManager is the Class, so the ApplicationManager itself is an object. "manager" is the variable name, while ApplicationManager is the variable type. The Application Manager class is already defined in "ApplicationManager.h", which was provided above. Could you please elaborate on your explanation? |
| arcaine01 is offline | |
| | #4 | |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Quote:
| |
| tabstop is offline | |
| | #5 | |
| Registered User Join Date: Apr 2008
Posts: 58
| Quote:
Well...here is the application class header. Code: #ifndef _APP_H_
#define _APP_H_
#include "d3dgraphics.h"
class Application
{
public:
Application(void);
~Application(void);
virtual void LoadContent();
virtual void UnloadContent();
void DrawStart(GraphicDevice);
virtual void Draw(void);
void DrawEnd(GraphicDevice);
virtual void Update();
void SetFrameRate(float value);
float FrameRate(void) {return _FrameRate;}
private:
float _FrameRate;
};
#endif
Here is D3DGraphics.h file Code: #ifndef _GRAPHIC_DEVICE_H_
#define _GRAPHIC_DEVICE_H_
#include <windows.h>
#include <d3d9.h>
#include "Window.h"
#pragma comment (lib, "d3d9.lib")
class GraphicDevice
{
public:
GraphicDevice(Window app);
void Dispose();
void Draw();
D3DPRESENT_PARAMETERS DeviceInfo() {return _DeviceInfo;}
LPDIRECT3D9 Interface() {return _Interface;}
LPDIRECT3DDEVICE9 Device() {return _Device;}
private:
D3DPRESENT_PARAMETERS _DeviceInfo;
LPDIRECT3D9 _Interface;
LPDIRECT3DDEVICE9 _Device;
};
#endif
Here is the window.h file Code: #ifndef _WINDOW_H_
#define _WINDOW_H_
#include <windows.h>
#include <windowsx.h>
#include "Point.h"
class Window
{
public:
Window(HINSTANCE currentHandle, int ShowCMD, bool fullscreen);
Window(HINSTANCE currentHandle, int ShowCMD, int width, int height, bool fullscreen);
Window(HINSTANCE currentHandle, int ShowCMD, int width, int height, int x, int y, bool fullscreen);
Window(HINSTANCE currentHandle, int ShowCMD, Point size, Point location, bool fullscreen);
~Window(void);
void Initialize(void);
int State(void);
int Width() {return _Width;}
int Height() {return _Height;}
int X() {return _X;}
int Y() {return _Y;}
bool isFullscreen() {return Fullscreen;}
HWND &Handle() {return WindowHandle;}
private:
WNDCLASSEX WindowObject;
HINSTANCE Instance;
HWND WindowHandle;
int _Width, _Height, _X, _Y;
bool Fullscreen;
protected:
};
#endif
All classes appear to be declared and define properly to me. Do you see any problems? | |
| arcaine01 is offline | |
| | #6 |
| Banned Join Date: Mar 2009
Posts: 533
| game.h creates an ApplicationManager object before you define the ApplicationManager class
__________________ ╔╗╔══╦╗ ║║║╔╗║║ ║╚╣╚╝║╚╗ ╚═╩══╩═╝ |
| ಠ_ಠ is offline | |
| | #7 |
| Registered User Join Date: Sep 2004 Location: California
Posts: 2,845
| The problem is you have a circular dependency. game.h includes applicationmanager.h, and applicationmanager.h inclues game.h. You need to forward declare ApplicationManager in game.h and remove the inclusion of applicationmanager.h. Then you can include applicationmanager.h in game.cpp. With this change, you will need to declare management as a ApplicationManager pointer, and then instantiate it in game.cpp. In other words: Code: #ifndef _GAME_H_
#define _GAME_H_
#include "application.h"
//#include "applicationmanager.h" note that this is commented out now
class ApplicationManager;
class Game : public Application
{
public:
Game();
~Game();
void LoadContent() override;
void UnloadContent() override;
void Draw() override;
private:
//int ApplicationManager; //WHY DOES THIS COMPILE??!
ApplicationManager* management; //This DOES NOT WORK?
};
#endif
|
| bithub is offline | |
| | #8 |
| Registered User Join Date: Apr 2008
Posts: 58
| wow lol...did not see game.h in the appmanager....Thank you VERY much for pointing that out! |
| arcaine01 is offline | |
| | #9 |
| and the hat of sweating Join Date: Aug 2007 Location: Toronto, ON
Posts: 3,119
| In your applicationmanager.h you have these two includes: Code: #include "game.h" #include "application.h"
__________________ "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008 |
| cpjust is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Code review | Elysia | C++ Programming | 71 | 05-13-2008 09:42 PM |
| failure to import external C libraries in C++ project | nocturna_gr | C++ Programming | 3 | 12-02-2007 03:49 PM |
| 30something GSOH seeks help with the basics of a minor programme | promsan | C Programming | 3 | 05-13-2007 08:55 AM |
| Working with random like dice | SebastionV3 | C++ Programming | 10 | 05-26-2006 09:16 PM |
| Warnings, warnings, warnings? | spentdome | C Programming | 25 | 05-27-2002 06:49 PM |