Need help with a pushback on a vector

Hi I'm trying to get my new section to work on a pushback to no avail. Not sure what I'm doing wrong here.

This is the main code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
  //headers
#include "Header.h"
#include <iostream>
#include<string>
#include <vector>


int main() {
	//creates team 
	std::vector<player*>team;
	//initializing and declaring variables
	int playerID, choice = 1, choice2=0;
	std::string name, position;

	std::cout << "This program is designed to create a team of football players based on their position.  You will also need to enter a player ID or number for each player. " << std::endl;
	//offense players prompt
	std::cout << "We need some offensive players." << std::endl;
	std::cout << "Please enter your offensive player/s." << std::endl;
	choice = 1;
	do {

		std::cout << "Please enter your player's name:";
		std::cin >> name;
		std::cout << "Please enter your player ID:";
		std::cin >> playerID;
		std::cout << "Please enter the position of the player ( 1 for Quarter Back, 2 for Wide Receiver, 3 for Tight End, 4 for Running Back, and 5 for Offensive Lineman).  ";

		do {
			std::cin >> choice2;
		} while (choice2 != 1 | choice != 2 | choice != 3 | choice != 4 | choice != 5);
		if (choice2 == 1) {
			position = "QuarterBack";
		}
		if (choice2 == 2) {
			position = "WideReceiver";
		}
		if (choice2 == 3) {
			position = "TightEnd";
		}
		if (choice2 == 4) {
			position = "RunningBack";
		}
		if (choice2 == 5) {
			position = "OffensiveLineman";
		}
		// not sure why new is not working here
		team.push_back(new offense(name, playerID, position));
		std::cout << "Would you like to continue (Press 1 to continue and anything else to move on.).";
		std::cin >> choice;
	} while (choice == 1);

	//defensive player prompt
	std::cout << "Offense will only go so far without defense. Enter some defensive players." << std::endl;
	choice = 1;
	do {

		std::cout << "Please enter your player's name:";
		std::cin >> name;
		std::cout << "Please enter your player ID:";
		std::cin >> playerID;
		std::cout << "Please enter the position of the player ( 1 for Defensive Lineman, 2 for Linebacker, 3 for Defensive Back).  ";
		do {

			std::cin >> choice2;
		} while (choice2 != 1 | choice != 2 | choice != 3);
		if (choice2 == 1) {
			position = "DefensiveLineman";
		}
		if (choice2 == 2) {
			position = "Linebacker";
		}
		if (choice2 == 3) {
			position = "DefensiveBack";
		}
		team.push_back(new defense(name, playerID, position));
		std::cout << "Would you like to continue (Press 1 to continue and anything else to move on.).";
		std::cin >> choice;
	} while (choice == 1);
	//special teams player prompt
	std::cout << " Now let's get to some of our most special players.  Enter some special teams players." << std::endl;
	choice = 1;
	do {

		std::cout << "Please enter your player's name:";
		std::cin >> name;
		std::cout << "Please enter your player ID:";
		std::cin >> playerID;
		//lets user select until condition it false
		std::cout << "Please enter the position of the player ( 1 for Kicker, 2 for Punter, 3 for Holder, 4 for Returner).  ";
		//no additional input validation is needed here since the do covers everything
		do {
			std::cin >> choice2;
		} while (choice2 != 1 | choice != 2 | choice != 3 | choice != 4);
		if (choice2 == 1) {
			position = "Kicker";
		}
		if (choice2 == 2) {
			position = "Punter";
		}
		if (choice2 == 3) {
			position = "Holder";
		}
		if (choice2 == 4) {
			position = "Returner";
		}
		team.push_back(new special(name, playerID, position));
		std::cout << "Would you like to continue (Press 1 to continue and anything else to move on.).";
		std::cin >> choice;
	} while (choice == 1);

	std::cout << "Here's your team:";


		std::cout << "Would you like to add any more players? Press 1 for Offensive Players, press 2 for Defensive, and press 3 for Special teams. ";
		std::cin >> choice;
		do {
			do {
				std::cout << "Enter another Offense Player" << std::endl;
				std::cout << "Please enter your player's name:";
				std::cin >> name;
				std::cout << "Please enter your player ID:";
				std::cin >> playerID;		
				std::cout << "Please enter the position of the player ( 1 for Quarter Back, 2 for Wide Receiver, 3 for Tight End, 4 for Running Back, and 5 for Offensive Lineman).  ";

				do {
					std::cin >> choice2;
				}while (choice2 != 1| choice !=2 | choice!=3|choice!=4| choice !=5);
				if (choice2 == 1) {
					position = "QuarterBack";
				}
				if (choice2 == 2) {
					position = "WideReceiver";
				}
				if (choice2 == 3) {
					position = "TightEnd";
				}
				if (choice2 == 4) {
					position = "RunningBack";
				}
				if (choice2 == 5) {
					position = "OffensiveLineman";
				}
				
				team.push_back(new offense(name, playerID, position));

				std::cout << "Would you like to continue (Press 1 to continue.  If you would like to add to another category press 1 for offensive players and 2 for defensive, press anythign other than 1 ,2 , or 3, to exit).";
				std::cin >> choice;
			} while (choice == 1);

			std::cout << "A good offense is a good defense.  Add you defense player: " << std::endl;
			choice = 1;
			do {

				std::cout << "Please enter your player's name:";
				std::cin >> name;
				std::cout << "Please enter your player ID:";
				std::cin >> playerID;
				std::cout << "Please enter the position of the player ( 1 for Defensive Lineman, 2 for Linebacker, 3 for Defensive Back).  ";
				do {
					
					std::cin >> choice2;
				} while (choice2 != 1 | choice != 2 | choice != 3);
				if (choice2 == 1) {
					position = "DefensiveLineman";
				}
				if (choice2 == 2) {
					position = "Linebacker";
				}
				if (choice2 == 3) {
					position = "DefensiveBack";
				}
				team.push_back(new defense(name, playerID, position));

				std::cout << "Would you like to continue (Press 2 to continue.  If you would like to add to another category press 1 for offensive players and 2 for defensive, press anything other than 1 , 2, or 3 to exit).";
				std::cin >> choice;
			} while (choice == 2);

			std::cout << "We need more special people here. Add your special player:" << std::endl;
			choice = 1;
			do {

				std::cout << "Please enter your player's name:";
				std::cin >> name;
				std::cout << "Please enter your player ID:";
				std::cin >> playerID;
				std::cout << "Please enter the position of the player ( 1 for Kicker, 2 for Punter, 3 for Holder, 4 for Returner).  ";
				do {
					std::cin >> choice2;
				} while (choice2 != 1 | choice != 2 | choice != 3 | choice != 4);
				if (choice2 == 1) {
					position = "Kicker";
				}
				if (choice2 == 2) {
					position = "Punter";
				}
				if (choice2 == 3) {
					position = "Holder";
				}
				if (choice2 == 4) {
					position = "Returner";
				}
				team.push_back(new special(name, playerID, position));

				std::cout << "Would you like to continue (Press 3 to continue.  If you would like to add to another category press 1 for offensive players and 2 for defensive, press anythign other than 1 ,2 , or 3, to exit).";
				std::cin >> choice;
			} while (choice == 3);
			
		}while (choice == 1 | choice == 2 | choice == 3);

		std::cout << "Thanks for using this program to create your football team!";

	return 0;
}

This is the header code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#include <iostream>
#include <string>

class player {
private:
	//private attributes of class player
	int playerID;
	std::string name;

public:
	//public attributes of class player
	player(int playerID, std::string name);
	std::string getName();
	int getPlayerID();
	std::string toString();
};
player::player(int playerID, std::string name){}

// getPlayerID returns playerID to user
int player::getPlayerID() {
	return playerID;
}
//getName returns name to user
std::string player::getName(){
	return name;
}

	//tostring() for basic player data
	std::string player::toString() {
		return "Name:" + name;
		return "Player ID: " + playerID;
}
//class for offense
class offense:player {
private: 
	std::string position;

public:
	offense(int playerID, std::string name, std::string position);
	std::string getPosition();
	std::string toString();
	//Am I suppose to put play method here or am I suppose to type it in the description section?
	
};
//defense class
class defense :player {
private:
	std::string position;

public:
	defense(int playerID, std::string name, std::string position);
	std::string getPosition();
	std::string toString();
	
};
//special class
class special :player {
private:
	std::string position;

public:
	special(int playerID, std::string name, std::string position);
	std::string getPosition();
	std::string toString();

};
//offense constructor
offense::offense(int playerID, std::string name, std::string position) :player(playerID, name){}
//defense constructor
defense::defense(int playerID, std::string name, std::string position) : player(playerID, name) {}
//special constructor
special::special(int playerID, std::string name, std::string position) : player(playerID, name) {}

//offense info tostring
std::string offense::toString() {
	std::string info;
	info = player::toString() + "Position : " + position + "/n Type: Offense /n Play Method: Throws ";
	return info;
}

//defense info tostring 
std::string defense::toString() {
	std::string info;
	info = player::toString() + "Position : " + position + "/n Type: Defense /n Play Method: Blocks";
	return info;
}

//special info tostring 
std::string special::toString() {
	std::string info;
	info = player::toString() + "Position : " + position + "/n Type: Special /n Play Method: Kicks";
	return info;
}

//get position for offense
std::string offense::getPosition() {
	return position;
}

//get position for defense
std::string defense::getPosition() {
	return position;
}

//get position for special teams
std::string special::getPosition() {
	return position;
}

//offense subclasses
class QuarterBack : public offense	
	{
	};
class WideReceiver : public offense
{
};
class TightEnd : public offense
{
};
class RunningBack: public offense
{
};
class OfLineman : public offense
{
};

//defense subClasses
class DeLineman : public offense
{
};
class Linebacker : public offense
{
};
class DeBack : public offense
{
};

//special teams subclasses
class Kicker : public offense
{
};
class Holder : public offense
{
};
class Punter : public offense
{
};
class Returner : public offense
{
};
Thanks ahead of time
1. It's || and not |. The former is logical, the latter is bit-combining. For your purposes || is short-circuiting, this is typically what you want.
2. All your inheritance needs to be public inheritance.
3. You keep passing arguments out-of-order
new offense(name, playerID, position)
playerID comes first:
new offense(playerID, name, position)
Topic archived. No new replies allowed.