Hey Everyone,
This is my first question I have posted on the forums so hopefully I do it right. Anyway straight to the point. So I was trying to make an Input Class for a win32 Window Application. I would like it to be a purely static class and inline class, but I ran into a problem. I have a private data type of an array of Booleans this is declared as:
staticbool mKeys[255];
now this is where my problem comes in. I know I must initialize it with:
bool Input::mKeys[255];
that should be in the c plus plus file or else unresolved link errors are thrown. But since its an inline class it all resides in the header file with no cpp file even created.
So here is my question:
Should I
1) Move everything into a CPP file and just use the inline specifier
2) Create a separate CPP file just used to initialize it (its literally 2 lines long)
or does anyone else have a different and secure way to initialize this static private class member?
Thanks for the help,
Taylor Coons (High School Student Programmer)
Here's my whole inline class if you would care to look at it:
Just initialize in a separate source file, even if it is really short. Note that moving your methods into the source file and using the inline keyword won't actually allow them to be inlined, since the compiler won't have access to the definitions when compiling source files that only include the header.