I've tried googling the answer, but it seems like all the answers I find don't exactly either make sense or something, could somebody please explain this to me.
I am trying to make a definitions class, so that I have static const data that I can use throughout my program. Here is my test code that I can't get to work:
#include <windows.h>
#include <string.h>
#define SYS_VERSION "0.01a"
#define SYS_CLASS "DAClass"
#define SYS_TITLE "Test App"
#define DEFAULT_WINDOWW 1024
#define DEFAULT_WINDOWH 768
#define DEFAULT_WINDOWX GetSystemMetrics(SM_CXSCREEN)/2-DEFAULT_WINDOWW/2
#define DEFAULT_WINDOWY GetSystemMetrics(SM_CYSCREEN)/2-DEFAULT_WINDOWH/2
#define DEFAULT_FULLSCREEN false
class Definitions
{
public:
static const char System_Version[strlen(SYS_VERSION)] = SYS_VERSION;
static const char System_Class[strlen(SYS_CLASS)] = SYS_CLASS;
static const char System_Title[strlen(SYS_TITLE)] = SYS_TITLE;
static const int Default_WindowWidth = DEFAULT_WINDOWW;
static const int Default_WindowHeight = DEFAULT_WINDOWH;
static const int Default_WindowX = DEFAULT_WINDOWX;
static const int Default_WindowY = DEFAULT_WINDOWY;
static const bool Fullscreen = DEFAULT_FULLSCREEN;
};
This gives me the following error:
Error 1 error C2864: 'Definitions::System_Version' : only static const integral data members can be initialized within a class ...
I know I could just use the #defines throughout, but I'm trying to take advantage of Intellisense to make life a bit easier when coding. I don't quite understand what this error means and I have had no luck finding an answer online. I'm mostly a self-taught programmer, so there's a lot of "key terms" etc that go above my head still, like "integral" ... no clue.
If anyone can explain how to fix this or an alternative to what I'm trying to do, please let me know. Thanks.