For context, I am implementing a user access system where people can log in to my application. The current logged in user is accessed by a pointer to a CUser
:
std::shared_ptr<CUser> m_pCurrentUser;
When a user logs out, I want this pointer to point to a "default" user that I have declared as a static const:
static const CUser xDefaultUser(L"Default", L"password", CUser::EAccessLevels::eAnon);
My first question is whether or not applying static const to the default user object is correct. My reasoning is that it should never change (const) and that I want it available for the lifetime of the application (static).
The second question is how I should assign the default user as the m_pCurrentUser
. Should I instead declare a const shared_ptr<CUser>
instead of a straight up object?
Aucun commentaire:
Enregistrer un commentaire