mercredi 18 mars 2020

Initializing an object of a class including a vector of pointers of other classes

I am new to c++ and I am writing a program to analyze the data from a website similar to Goodreads. Inside a class called User I have a public function called add_user that reads the data from a csv file and wants to return a User object.I have other classes called Date , Author , Book and a class including vectors of them all called Goodreads. When I return the User object inside the add_user function I get the "no matching function for call to User::User(int& ...)" error.Here are my User class and the object inside add_user function:

class User
{
public:
  User(string i, string n, string pob, string m, int d, int y, vector<Author*> fav_aus, vector<string> fav_genres
      , vector<Book*> wtr, vector<Book*> cr, vector<Book*> r);

private:
  string id;
  string name;
  string place_of_birth;
  Date member_since;
  vector<Author*> favorite_authors;
  vector<string> favorite_genres;
  vector<Book*> want_to_read;
  vector<Book*> currently_reading;
  vector<Book*> read;
  vector<User*> followings_id;
  vector<User*> followers_id;

};

User::User(string i, string n, string pob, string m, int d, int y, vector<Author*> fav_aus, vector<string> fav_genres
    , vector<Book*> wtr, vector<Book*> cr, vector<Book*> r)
    :member_since(m, d, y),

{
  id = i;
  name = n;
  place_of_birth = pob;
  favorite_authors = fav_aus;
  favorite_genres = fav_genres;
  want_to_read = wtr;
  currently_reading = cr;
  read = r;
}

User Goodreads::add_user(string user_line)
{
...
  return User(user_id, user_name, user_place_of_birth, user_member_since.get_month(), user_member_since.get_day(), user_member_since.get_year()
        , user_fave_authors, user_fave_genres, user_want_to_read, user_currently_reading, user_read);
}

Aucun commentaire:

Enregistrer un commentaire