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

Change a char to int* in push_back(); of vector

I have this problem, I try to change a char to int, but nothing happens. This is the code: #include #include using namespace std; vector m,n; void my_f() { bool *quad; quad=new bool; *quad=false; …
Math
  • 19
  • 5
0
votes
1 answer

Opencv push_back image Mat into vector

I try to read images from a file folder into a vector. However, it seems like my image Mat fail to push_back in to the vector. The result of cout << "img vec:" << imgs[0].rows << " " << imgs[0].cols << endl; is img vec:0 0. I've tried both…
user4029119
  • 145
  • 1
  • 4
  • 10
0
votes
2 answers

Display Values inside Vector array

I am using a code that stores points into a Vector data type as follows: RECT head; head.left = pt1.x; head.right = pt2.x; head.top = pt1.y; head.bottom = pt2.y; detectBox->push_back(head); This falls inside a function that…
James Mallett
  • 827
  • 4
  • 11
  • 27
0
votes
1 answer

Linked List pushback member function implementation

I am a novice programmer and this is my second question on Stack Overflow. I am trying to implement a pushback function for my Linked List by using a tail pointer. It seems straightforward enough, but I have a nagging feeling that I am forgetting…
Ryan Swanson
  • 89
  • 3
  • 7
0
votes
2 answers

vector push back clarifying

I can't figure out how push_back(const value_type& val) exactly works, in docs it says about val that val is Value to be copied (or moved) to the new element ... How it can be copied when it takes val by reference ? Will that copying ever call the…
ampawd
  • 968
  • 8
  • 26
0
votes
0 answers

SIFT detects 0 keypoints?

I'm creating the visual histograms (following the Bag of Visual Words model) of a dataset of n images using OpenCV. This is the code: std::vector fileList; std::unique_ptr bowDE; cv::Mat…
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
0
votes
1 answer

Improper indexing of 3 dimensional vector

Here is my function. Basically it reads a text file and organizes data into a bunch of different vectors. ctrlpts is a 3-dimensional vector. The first level stores the different sets of control points (cp1..cp3). The second level stores x,y,z,w…
Mike James Johnson
  • 724
  • 2
  • 8
  • 29
0
votes
1 answer

How can I move an element to the end of a vector?

int main(){ std::vector vec; vec.push_back(1); vec.push_back(2); vec.push_back(vec[0]); for (auto it = vec.begin(); it != vec.end(); it++) { std::cout << *it << std::endl; } return 0; } This outputs [1, 2,…
ygongdev
  • 264
  • 3
  • 19
0
votes
1 answer

Premature end of execution due to a vector.push_back() [C++]

Good morning everyone, I currently have an issue in my code, it crashes without any error output. I was hopping you could lend me a hand! The issue occurs when I append an element at a vector, but not at the first iteration always at the…
0
votes
2 answers

C++ vector pushback method and temporary object creation

Below is the signature of vector pushback method in C++. void push_back (const value_type& val); Now below is code class MyInt { int *a; public: MyInt(int n):a(new int(n)){cout<<"constructor called"<
Neeraj Kumar
  • 836
  • 1
  • 10
  • 29
0
votes
4 answers

push_back struct into vector

//prototype void Split(char c, vector &outputVector) const //partial code inside split function // create new MyString object to push into output vector MyString substr; substr.mString = newString; substr.mLength =…
0
votes
1 answer

Creating a thread(out of a vector) of a function with arguments

I have a problem when using a vector of threads. I want to create a thread for each client in a server. So I have function called NewClient that once the connection is started, does all the necessary things for the client. This function is defined…
19mike95
  • 506
  • 2
  • 4
  • 19
0
votes
2 answers

Error using std::map::at

I have a map defined as: map > data; Where std::string refers to a username (Primary key) and std::vector to the messages corresponding to a particular username. Message is a struct containing message…
euskadi
  • 127
  • 1
  • 14
0
votes
3 answers

Push_back method of vector of pointers causes crash C++

I'm trying to add pointers to a vector in C++. As such: Puzzle * puzzleStart = new Puzzle(); std::vector OPEN; OPEN.push_back(puzzleStart); The first time a pointer is pushed, there is no problem. The…
0
votes
0 answers

vector.push_back working with adding object pointer but not with adding object

I am trying to implement a stack using a set of sub-stacks of fixed length. For the sub-stack, I use a simple array of fixed length initialized in the constructor. For the stack, I use a vector of sub-stacks. The below push method tries to allocate…
Ankit
  • 115
  • 10