
In server.hpp, there is a definition of MAX_SESSIONS
It is in global scope, any source or header file that includes this header will now have the definition of MAX_SESSIONS in their namespace, yet they will have nothing to do with it because it's an implementation detail of the server class
You should ditch the #define, and instead just declare it as a private member of the server class:
static contsexpr size_t kMaxSessions = 10
or
static const size_t kMaxSessions = 10
The advantage of this method:
- Can view the variable in a debugger
- Encapsulation: users outside of the class can no longer see this
Disadvantage is that some functions in server.cpp will not be able to access it because they're not all members of the server class, in this case you will have to add them as static functions
In server.hpp, there is a definition of MAX_SESSIONS
It is in global scope, any source or header file that includes this header will now have the definition of MAX_SESSIONS in their namespace, yet they will have nothing to do with it because it's an implementation detail of the
serverclassYou should ditch the #define, and instead just declare it as a private member of the
serverclass:static contsexpr size_t kMaxSessions = 10or
static const size_t kMaxSessions = 10The advantage of this method:
Disadvantage is that some functions in server.cpp will not be able to access it because they're not all members of the
serverclass, in this case you will have to add them asstaticfunctions