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

std::vector crash with push_back. in VS2008

I've a structure DutPlayerArrayElement defined in following lines: namespace Common { namespace Constants { const int MaxNumberOfIPAddresses = 10; const int NumberOFRFOutputs = 100; const int NumberOfPlayers = 100; const int…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
0
votes
2 answers

Why does my multidimensional vector only push_back 0 index?

I having a problem using push_back(), I can't figure out why only the first cols vector is just pushed over and over again. Input 10 9 10 3 100 8 7 10 73 9 10 5 9 87 -1 8 3 7 10 92 6 10 6 83 9 11 8 8 77 -1 10 10 10 10 100 10 10 10 100 10 10 10 10…
nipponese
  • 2,813
  • 6
  • 35
  • 51
0
votes
1 answer

Can't deque.push_back() 10 million+ deques

I'm a student, and my Operating Systems class project has a little snag, which is admittedly a bit superfluous to the assignment specifications itself: While I can push 1 million deques into my deque of deques, I cannot push ~10 million or…
ArnieJ
  • 17
  • 6
0
votes
2 answers

Is there a way to push_back multiple variables into a vector in a for loop?

such as pushing back using a holding variable book (title, author, ISBN) vector books; Book book1("a", "Jim John", 1000); Book book2("b", "Jim John", 1001); Book book3("c", "Billy Bill", 1002); Book book4("d", "Greg Lumburge", 1003); Book…
user3549747
  • 35
  • 1
  • 1
  • 6
0
votes
1 answer

Can't use vector defined in class header in C++

I have a route class. In header, i defined private: QVector cameraPoints; In class source, void Route::SetCameraPositions(QVector *cam) { QVector bla; QPoint t; int x,y; for(int i=0; isize(); i++) { …
Ulfsark
  • 902
  • 1
  • 11
  • 26
0
votes
0 answers

String Vector showing duplicates C++

Not working Code: #include "stdafx.h" #include #include "sqlite3.h" #include #include #include #include using namespace std; std::vector emailsfound; static int callback(void *data, int…
Hawaiian Pizza
  • 144
  • 1
  • 1
  • 10
0
votes
1 answer

Error when trying to push back a tuple into a const vector

I have the following vector: const vector> &v; I want to add tuples to this vector, so I did the following: tuple newOne = make_tuple(0,2); v.push_back(newOne); The error message I got was: "No matching member function for…
user3025403
  • 1,070
  • 3
  • 21
  • 33
0
votes
3 answers

VB.NET Array of structure: No .push_back available?

I have defined a structure in VB.NET and created an array from it: Public Struct MyStruct Dim SomeValue As String Dim SomeOtherValue As Double End Struct Public MyArr() As MyStruct I am wondering if there is no .push_back function…
tmighty
  • 10,734
  • 21
  • 104
  • 218
0
votes
3 answers

C++ Only first vector completes, push_back, cin, for loop

I am sure that I am making some obvious mistake. I googled my question but I could not find a similar question; apologies if it is there somewhere. Basically, I just want to complete entries for a series of vectors. The programme compiles, and I can…
0
votes
1 answer

Push_back in 2 dimension vector of objects

I have got a vector of objects vectors named "circuito"(circuit) in a "factory" class named "FactoryCircuit". vector< vector< Elemento*> > "Elemento" is a base class of three derived class named…
Keys88
  • 1
0
votes
1 answer

Converting a string to a float before push_back in C++

I've got a large collection of CSV lines that I'm breaking up line-by-line, splitting up by the commas, and placing those tokens in a vector. Here's the little code snippet where I handle the last two items in that sentence: //token for parser …
nerdenator
  • 1,265
  • 2
  • 18
  • 35
0
votes
3 answers

c++ vector - what's the difference between push_back(*new obj()) and push_back(obj())?

I am currently having an issue related to: vector myVector; Q1. Please tell me the difference between the following two lines: a) myVector.push_back(*new myObj()); b) myVector.push_back(myObj()); NOTE: I realise that line a) is bad practice…
mindTree
  • 916
  • 9
  • 18
0
votes
6 answers

Infinite loop reading from stdin using cin::fail()

I'm struggling with a vector push_back function. The goal is to have a function which pushes n number of elements until you decide to stop. So my idea of a 'stop', is cin.fail(). The faulty function is void pushbackVector(vector &data) { …
Anton Antonov
  • 1,217
  • 2
  • 14
  • 21
0
votes
1 answer

json-spirit - adding content to an object in an arry

Background: I want to represent a deep hierarchy using JSON. I.e A Job has nodes, nodes have CPUs, CPUs have device loops and loops have devices. My data is on a database. I am using the visitor pattern to call back VisitJob, VisitNode, VisitCPU as…
BryanT
  • 412
  • 3
  • 12
0
votes
3 answers

C++ vector push_back() overwrites on another vector of the same type?

I defined a class named nth_best_parse this way: class nth_best_parse { public: int traversal; int nth_best_active; int nth_best_passive; double viterbi_prob; nth_best_parse(); …
Onur Cobanoglu
  • 211
  • 1
  • 6
  • 9