how can I update a variable in an object of vectors
I want to update an object’s variables within a vector array of objects, using input from the user as to what variable they wish to update.
how can I update a variable in an object of vectors
I want to update an object’s variables within a vector array of objects, using input from the user as to what variable they wish to update.
How much memory could std::vector consume when expanding?
In most compilers of Linux, std::vector
will expand with the factor of 2. I have tested that on g++11.
Print floats of a vector and respective quantity of each
I’ve been trying to code a program in C that, given a float vector, determines how many of each number there are, and then, prints each number and their respective frequency. This is an exercise from my college (computer science course). In total, I must have spent like 3 hours trying to think about a solution and I just can’t think. I’m certain this is trivial, though. But I’m stupid.
C++ Initializing std::vector that has unique_ptr in it
I’m having much of a difficulty with what seems to be a simple task, yet after trying out different things I have no idea on how to solve this.
Copying all items in vector of class obj. between min and max values (by field) to another vector and then removing them
So I’m new to cpp, and I have a program that finds min and max values in vector of class objects ( by field ) and I need to move all the items in between them into another vector and then remove them from the original vector. I cant wrap my head around it, how do I iterate through the vector with an iterator and check the condition (it > minVal && it < maxVal).
Change index of element in C++ std::vector
I am trying to change the position of an element in an array. The way I am currently doing this is by inserting the element into its new index, and then erasing the old element at the old index. Is there a better way to do this?
Erasing an element from a vector in C++
I’m trying to remove the negative elements from a vector (lesser than 0) using the below code, however whenever a vector has a negative as its last element I’m getting an error(Segmentation fault)
How to take input from the user to initialize vector of vectors in C++
Here’s my piece of code where I’m trying to take input from the for the 2D vector, however I’m getting segmentation fault when I’m trying to enter the input. I’m trying to use insert member function instead of push_back.