• Register

Recent questions tagged vector

0 votes
1 answer 8 views
Problem: I am given a task to write a loop that subtracts 1 from the values given in a vector. I have not worked with vectors a lot. Here are the values that are to be used in the vector: 4,1,8,-2,5,-1,0 I am looking for a complete program that can solve this problem. Thanks!
asked 3 days ago Code Learner 6.2k points
0 votes
1 answer 6 views
Problem : Error: No matching member function for call to 'push_back'
asked Feb 23 Shovo210 3.1k points
0 votes
1 answer 8 views
Problem: here is we can find max element in vector c++
asked Feb 15 jasimchaudary 640 points
0 votes
1 answer 4 views
0 votes
1 answer 10 views
Problem: I am trying to sort an array of strings, but it's not sorting anything.... what am I doing wrong? string namesS[MAX_NAMES]; int compare (const void * a, const void * b){ return ( *(char*)a - *(char*)b ); } void sortNames(){ qsort(namesS, MAX_NAMES, sizeof(string), compare); }
asked Dec 25, 2020 Mashhoodch 9.9k points
0 votes
1 answer 15 views
Problem Hey, I want to learn how to remove the first element from a vector by using C++.
asked Dec 20, 2020 chris jordan 2.4k points
0 votes
1 answer 4 views
Problem Hey, I want to know about vector push back function. Answer me with the help of an example including syntax.
asked Dec 15, 2020 chris jordan 2.4k points
0 votes
1 answer 8 views
Problem: When we pass an array to a function, a pointer is actually passed. When a vector is passed to a function, a copy of the vector is created. For example, we can see below program, changes made inside the function are not reflected outside because function has a copy.
asked Dec 15, 2020 Mashhoodch 9.9k points
0 votes
1 answer 7 views
Problem: I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the first parameter of the for loop is always something based on the vector. In Java I might do something like this with an ArrayList: for(int i=0; i < vector.size(); i++){ vector[i].doSomething(); }
asked Dec 15, 2020 Mashhoodch 9.9k points
0 votes
1 answer 11 views
Problem: Finally, note that vectors of objects can exist. This does not mean, however, that the new objects are instantiated when the array is declared. Arrays take up a fixed size in memory, and the size of an object isn't defined when it is instantiated. Therefore, the objects ... code could be used? object_list = new Object[5]; object_list[0] = new Object(); object_list[1] = new Object(); . .
asked Dec 5, 2020 Mashhoodch 9.9k points
0 votes
1 answer 15 views
Problem: I am using the library to perform calculations with matrices, vectors, and other methods. To speed up compile times, I'm trying to compile the instantiations into a single file, and declare all the templates as externthe files .cppthey are used in: // A file ... Is there a difference between explicit instantiation and on-the-fly instantiation ? What am I doing wrong ? How do I solve it ?
asked Dec 4, 2020 sasha 13.2k points
0 votes
1 answer 53 views
Problem Hey, I just want to know that how to convert std::vector into array[ ] in c++
asked Nov 18, 2020 chris jordan 2.4k points
0 votes
1 answer 17 views
Problem: I am making an RGB pixel array from bottom to top to top-bottom. I have checked the value of something and it gives me the expected result. No value is greater than obj.size () and no value is less than 0, I don't know what happens: std::vector<std::string> BMP_READER: ... (obj.size() - i) - (x_width*h); // error std::string val = obj[something]; new_v.push_back(val); } } return new_v; }
asked Nov 12, 2020 sasha 13.2k points
0 votes
1 answer 40 views
Problem: I am making a program which consists of solving a 2x2 equation, for this I used the Cramer method, the problem is not how to solve it, but it throws an error when executing it, and I suspect that it is because I used methods of the Matrix class Inside the Vector class ... " using namespace std; int main () { cout << "As long as the program compiles well it is enough" << endl; return 0; }
asked Nov 5, 2020 sasha 13.2k points
0 votes
1 answer 40 views
Problem: I want to remove elements from a vector. Is there any mechanism that C++ provides to remove elements from the vectors? How can I remove the elements from a vector??
asked Oct 22, 2020 Code Learner 6.2k points
0 votes
1 answer 8 views
Problem: I want to know what is the difference between insert() and push_back function of Vector class? When should I use insert() function and when should I use push_back?
asked Oct 21, 2020 Code Learner 6.2k points
0 votes
1 answer 24 views
Problem: I want to check the length of a vector that I initialized and the length of a vector that is initialized dynamically by the user at run time. How I can do that? If possible, please give the examples.
asked Oct 21, 2020 Code Learner 6.2k points
0 votes
1 answer 83 views
Problem: I am currently learning vectors in C++. I am trying to dynamically initialize my vector but insert() function is throwing some sort of error. How can I initialize a vector dynamically in C++?
asked Oct 21, 2020 Code Learner 6.2k points
0 votes
1 answer 29 views
I noticed in Effective STL that Vector is the type of sequence that should be used by default. What is the difference between list and vector in C++?
asked Oct 9, 2020 sikandar 2.4k points
0 votes
1 answer 39 views
What are the differences between an array and a vector in C++? An example of the differences might be included libraries, symbolism, abilities, etc.
asked Oct 9, 2020 sikandar 2.4k points