class User{
private :
std::string displayname;
std::string username;
std::string password;
public :
User(std::string username, std::string displayname, std::string password)
};
and somewhere in main I try to construct an object of user like this:
User user(username, displayName, password);
(username , displayname and password are strings that I've checked them and they are ok.)
when I try to print this user's information there is nothing to be printed. It's somehow like the constructor doesn't store any of this strings. Could u plz tell me how to solve this? :(
I'd appreciate your helps on it. thanks :)
Well just to make sure (since I'm not sure if you just didn't post the full constructor), in the constructor's body there needs the actual parameters need to be assigned to the private members.
You didn't actually show what's inside your constructor, User user(username, displayName, password); merely tells your program what the arguments for your constructor are. You need to define your function outside the class, like so for instance: