gpt4 book ai didi

c++ - 如何将对象添加到另一个类中的 vector
转载 作者:行者123 更新时间:2023-11-28 08:25:34 29 4
gpt4 key购买 nike

#include "player.h"

class team
{
public:
team();
void addPlayer(player);
void deletePlayer(int);
double getTotalCost();
int getPlayerCount();
double inBank();
string toString();

private:
player a;
int playerId;
double bank;
int i;
};


#include "../../std_lib_facilities.h"
#include "team.h"


team::team()
{
vector <player> a;
player a;
}

team::addPlayer(player)
{
a.push_back(a);
}

如果需要更多信息,请询问。提前感谢您的帮助。

最佳答案

我想这就是你的意思:

#include "player.h"
#include <vector>

class team
{
public:
team();
void addPlayer(player);
void deletePlayer(int);
double getTotalCost();
int getPlayerCount();
double inBank();
string toString();

private:
vector<player> a;
int playerId;
double bank;
int i;
};

#include "../../std_lib_facilities.h"
#include "team.h"


team::team()
{
}

team::addPlayer(player p)
{
a.push_back(p);
}

关于c++ - 如何将对象添加到另一个类中的 vector<object> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4183265/

29 4 0