You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bool valid() const: Returns true if the constructor could successfully do its work. If not, it returns false, in which case the return values of the other member functions are all invalid.
What would be the correct way to do this? I have it initialize to false and set it to true at the end now:
User::User()
:
d_valid(false)
{
d_userId = geteuid(); // identify current user
passwd *pw = getpwuid(d_userId); // passwd file for current user
d_name = string(pw->pw_name);
d_groupId = pw->pw_gid;
d_homeDir = string(pw->pw_dir);
d_realName = string(pw->pw_name);
d_shell = string(pw->pw_shell);
d_valid = true;
}
But to have all values end up invalid I would need to more code, which seems convoluted.
The text was updated successfully, but these errors were encountered:
The exercise requests the following:
What would be the correct way to do this? I have it initialize to false and set it to true at the end now:
But to have all values end up invalid I would need to more code, which seems convoluted.
The text was updated successfully, but these errors were encountered: