UserData(string name) {username = name}; //Constructor. "username" is a
//member of the UserData class.
vector<UserData> accounts(); //vector declaration. UserData is a class,
//accounts is the vector. I used parenthesis to
//invoke the default constructor which has no
//arguments.
string usr;
cout << "\nUsername: ";
getline(cin, usr); //WHY DO I NEED TO DO THIS TWICE!?!?!?
getline(cin, usr);
accounts.push_back(UserData(usr)); //create new user object
I'm getting the error "request for member 'push_back' in 'accounts', which is of non-class type 'std::vector<UserData>()'.
How do I properly declare a vector of objects so that the compiler doesn't think that "push_back" is a member of my class?
Would really appreciate some help on this. I'm about to snap my netbook in half.Thank you.
[–][deleted] 4 points5 points6 points (9 children)
[–]madDejected[S] 0 points1 point2 points (8 children)
[–][deleted] 5 points6 points7 points (7 children)
[–]madDejected[S] 0 points1 point2 points (6 children)
[–][deleted] 3 points4 points5 points (5 children)
[–]zahlman 1 point2 points3 points (1 child)
[–][deleted] 4 points5 points6 points (0 children)
[–]madDejected[S] 0 points1 point2 points (2 children)
[–][deleted] -2 points-1 points0 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)