Initialize empty vector in structure - c++


I have a struct:

typedef struct user {
    string username;
    vector<unsigned char> userpassword;
} user_t;

I need to initialize userpassword with an empty vector:

struct user r={"",?};

What should I put instead of ??


Answers:


Both std::string and std::vector<T> have constructors initializing the object to be empty. You could use std::vector<unsigned char>() but I'd remove the initializer.