C++ Vector of pointers

后端 未结 4 996

For my latest CS homework, I am required to create a class called Movie which holds title, director, year, rating, actors etc.

Then, I am required to read a file which c

4条回答
  •  借酒劲吻你
    2021-01-31 10:12

    It means something like this:

    std::vector movies;
    

    Then you add to the vector as you read lines:

    movies.push_back(new Movie(...));
    

    Remember to delete all of the Movie* objects once you are done with the vector.

提交回复
热议问题