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
0 answers

Getting started with boost mpl with vector and push_back

I've been scratching my head for far too long, I'm finding using MPL very difficult to get around and hoping somebody can get me started. Here is some partial code from a class I am developing which does not use MPL. I eventually want to implement…
woosah
  • 843
  • 11
  • 22
0
votes
2 answers

c++ vector push_back not working

My program crashes here: void TriangleStrip::addTriangle(Triangle t){ cout << t < instances; I call addTriangle here: TriangleStrip* s; int c =…
0
votes
2 answers

Segfault with std::list usage

I'm Java user coming over to C++, and I am having a hard time understanding what is going wrong with this statement. My program has been segfaulting anywhere I put the push_back command. So I'm wondering what exactly is going on. class Process { …
AndrewD
  • 258
  • 4
  • 17
0
votes
1 answer

push_back not adding numbers to vector c++

I'm trying to debug my mergesort program, which seems to be problematic somewhere inside the "merge" function when i try to use "push_back" to add values from either the vector "left" or "right" to "mergedList". The following is an excerpt from the…
cdeist
  • 229
  • 2
  • 6
0
votes
2 answers

Segfault on push_back

In piece of code below, I get a segfault on the line calling push_back(): CTrigger CTriggerManager::AddTrigger(const std::wstring& eventName) { CTrigger trigger(eventName); m_Triggers.push_back(trigger); return trigger; } In case it is…
zoot
  • 3
  • 1
  • 2
0
votes
3 answers

Vector Push_back

Possible Duplicate: Empty check with string split I split the below string with '&' and saved it in a vector const vector vec = split("f0=fname0&l0=lname0&f1=fname1&l1=lname1&f2=fname2&l2=lname2&f3=&l3=","&"); Now i'm again splitting the…
Smith Dwayne
  • 2,675
  • 8
  • 46
  • 75
0
votes
1 answer

modifying vector at same iterator

Suppose i have the following vector: std::vector > myV; std::vector >::iterator it; And then i initialize them for 10 row: for (i = 0 ; i < 10; i++){ if (i % 2 == 0 ) j =…
PersianGulf
  • 2,845
  • 6
  • 47
  • 67
0
votes
1 answer

Values from vector differ from the original value

I am confused with C++ vector and ask for help. I declare a class CBoundaryPoint: class CBoundaryPoint: { public: double m_param; int m_index; } And then I define a vector: vector vBoundPoints; CBoundaryPoint bp; double…
tlanyan
  • 3
  • 1
0
votes
2 answers

Vector_push back not populating the vector (c++)

I'm not getting any error messages, simply my vector is not populating. Looking at the vector in the watch list, nothing is being copied. Why is this? I've tried two ways. The first std::vector hitpoints; local_hit_point =…
Seb
  • 3,655
  • 3
  • 17
  • 17
-1
votes
0 answers

Why is my c++ vector not pushing back new items, and not printing?

I am working on a very vague assignment and really trying my best here. I almost have it finished, but for some reason my vector is NOT push_back()-ing correctly It is taking a number and pushing it into the vector, but any subsequent pushes, just…
johnthor
  • 1
  • 5
-1
votes
2 answers

C++ Question about .append() vs .push_back() for Strings and Characters (Beginner Question)

I have a question regarding which functions work for appending strings. In this particular code, it asks: Given string givenInput on one line and character extension on a second line, append extension to givenInput. Ex: If the input is: Hello ! then…
user22099685
-1
votes
1 answer

what is the difference between vector.push_back() and inserting element like Vector[index]?

class Solution { public: vector getConcatenation(vector& nums) { int n=nums.size(); vector ans(2*n); for(int i=0;i<2*n;i++) { if(i
-1
votes
1 answer

list.push_back() not working: throws error C++

#include #include using namespace std; string song = "CDE"; int songlength = song.length(); int counter = 0; int main() { cout << songlength << endl; for (int i = 0; i < songlength + 1; i++, counter++) { …
Skey
  • 45
  • 4
-1
votes
2 answers

std::list push_back unrelated types

Is it possible to push_back to a list of userClass a variable with different type? list* myList list* NewData // -- ..some population of NewDat.. -- myList->push_back(NewData);
AnR
  • 81
  • 7
-1
votes
1 answer

how to pushback a 2D vector

let's say I have a vector storing vectors of strings. std::vector> MyVec = { {}, {} } I want to use anything equivalent to .push_back(X) such that the vector will now look as following: { {X}, {} }. Does anyone have an idea…
Itay123
  • 61
  • 1
  • 6