Click here to Skip to main content
16,020,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Specify a void Party class function named add_new_player (). This function will accept a string to represent a new member of the party and add it to the vector players.


What I have tried:

I've tried to use insert.. but i dont know how to use it because im new on coding c++
Posted
Updated 30-Mar-20 4:58am

1 solution

If you are new to C++ I strongly recommend reading a book for beginners or attending online video course. But it would look something similar to:

C++
#include<vector>
#include<string>

class Party{
   std::vector<std::string> m_members;

public:
   void add_new_player (const std::string& val){
      m_members.push_back(val);
   }

   // Add remaining functionality here...
};
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900