Questions tagged [push-back]

is the action of adding an element at the end of a container.

push-back is the action of adding an element at the end of a container.

420 questions
0
votes
1 answer

vector wont push class function c++

I am attempting to make a text adventure sort of game, and I would like to avoid a bunch of conditionals, so I am trying to learn about the classes stuff and all that. I have created several classes, but the only ones that pertain to this problem…
user4127117
0
votes
2 answers

C++ Reading a file line by line with delimiter and store data into a list

I have a class called Task that have //Attributes int earliestStartingTime, earliestEndTime, latestStartingTime, latestEndTime, duration, differ; char TaskPosition; list predecessors; list successors; //Constructor …
DrD4rk
  • 57
  • 1
  • 11
0
votes
2 answers

C++ Pushback vectorMyVector And Error C2664

First of all I'm pretty new to vectors themself, so bear with me please. I'm trying to make a vector that contains 2strings, int and a float. This is my struct: struct OpiskelijanTiedot { string etunimi; string sukunimi; int HarjMaara; …
weku
  • 3
  • 3
0
votes
1 answer

A class derived from Cocos2d::Layer has a Pointer Data Member. This member also has vector container. When vector::push_back is called it crashes

I Edited this with my best effort. Hopefully it's now Minimal, Complete, and Verifiable Example - I am using Cocos2dx V3.6 for our current game The problem I am describing only happens within the custom derived classes from cocos2d::Layer cocos2dx…
Yucel_K
  • 688
  • 9
  • 17
0
votes
1 answer

C++ : List Seg Fault

Can anyone explain me why does this happened? When I call member function printEvent() inside the block of if-else,I get the correct output,but when I call printEvent() after the block I get this unknown result. list currentEvents; …
Nikolas
  • 161
  • 1
  • 12
0
votes
2 answers

C++ vector only save the last push_back value

I am a newbie, I have a problem which trouble me a lot. Please help me out. I am trying to save char array values in a vector. The size of the vector is the same as the number I push_back. However, all the values in the vector is the last value I…
xxhaxin
  • 11
  • 3
0
votes
1 answer

Vector as Objects, push_back error - expected primary expression before "(" token

for(int i = 0; i < classSize; i++){ cout << "Enter Student Name: "; cin >> name; cout << "Enter Student Grade: "; cin >> grade; Student(name, grade); newMyClass.push_back(Student); cout << endl; } The…
0
votes
1 answer

Increase capacity for vector

Disclaimer 1 - I'm new to programming Disclaimer 2 - I have searched and searched, but can't find the help I'm looking for. For a project, I am more or less re-writing the vector class in a more stripped down form. The part I'm hung up with is…
pocket86
  • 33
  • 6
0
votes
0 answers

C++ OpenGL Recursive Push_Back Doesn't Work

A problem has risen in my OpenGL code which looked so simple but it doesn't seem to work like I expected it to be. The code is as follows: int x = 0, y = 0, z = 0, TP = 1; bool initiate_placement = true; float trans[3][3][2] =…
0
votes
1 answer

How to push_back values in the middle of a row of 2D array using std::vector?

I am new to std::vector and my problem may have a very simple solution but i am not aware. For this code, #include #include using namespace std; int main() { vector > grid; vector col; …
explorer
  • 283
  • 4
  • 10
0
votes
1 answer

NullReferenceException on push_back

I am getting a nullReferenceException when using vector.push_back on a new object. In the code segment you see I have the vector object as a pointer but I originally had it as a non-pointer, I changed it in my troubleshooting out of desperation. I…
UberAffe
  • 332
  • 2
  • 3
  • 15
0
votes
1 answer

String not getting stored in vector?

#include #include using namespace std; int main() { string n, m; vector dingdong; cin >> n; dingdong.push_back(n); cin >> m; dingdong.push_back(m); for (int i = 0; i <2; i ++) { …
Jahaha
  • 29
  • 4
0
votes
1 answer

structure vector push_back C++

I'm having a problem figuring out how to use push_back function to push array elements of a structure into the TeamV vector. Here is the code i have so far: const int MEMBERS = 3; const int TEAM_NUM = 4; struct TeamS { int ID_NUM; string…
0
votes
3 answers

vector push_back shows absurd result

I am trying to make a vector out of several integers by overloading the operator << and conversion operator. However, when I test my code, I observe some absurd results. The printed output should be 1 2 3 4. But it actually print out something like…
0
votes
0 answers

STL list push_back crashes when called from a pointer list

I have a problem that arised with another question I made. I am using a list of pointers of a custom class (class that I have implemented), and the program crashes when I call this method, however, if I do not use a pointer list, it works fine. This…
dpalma
  • 500
  • 5
  • 20