vector

A pair of vectors or a vector of pairs

Which will be more productive in the general case: a vector of pairs or 2 vectors, where each contains its own element? The ... r operations: getting one of the values of the pair by the index, adding the pair to the end, removing the pair from the end.

Accessing the vector container that is inside the map container

There is a container map<string,vector<string>> Map. You need to find a specific word in the vector and output its key. Hence the question: how to access the vector that is inside the map?

Inheritance and use of a static vector in C++

There is a base class in which I need to have a static vector, where I will enter some values in the constructors of the inhe ... allocator@N@std@@@std@@A)" How right organize a vector in the base class so that all the inheritors can enter values in it?

How to multiply two binary numbers modulo 2 that are stored as strings

Example: In the zero position, the highest digit of the binary number is stored. The result is a number consisting of digits ... return t; } But it turns out that it counts incorrectly, that is, the answer does not match what is in the picture.

How do I move an object in a certain direction, regardless of where it is turned?

There is an object, it moves in a certain direction like this: transform.Translate(0,0,speedTime.deltaTime); There is a secon ... getting the coordinates of the first object and assigning it to the second one is not veren, you need exactly the direction.

C++vectors don't work

I'm working on a 2D game in SFMl c++. but I think it is not important. There is a World class. It has a string type vector ( ... the code, I specified a possible string due to which occurs error ATTENTION! the error is not the build, but the execution!

Call of overloaded is ambiguous when implementing its copy algorithm

There is a self-written similarity of stl. The essence of the problem is a vector of pairs (also self-written). The problem ... 0; } P.S. This is something like training on cats (to avoid comments like "why all this is necessary, if there is an stl").

"The Euler Project". Task.

I decided to solve problems from the "Euler Project". I started with the simplest ones, and then there was a snag. Here is th ... CKS_PER_SEC << endl; cout << length << endl; cout << number << endl; return 0; }

Constructing a vector in C++11 breaks the old code

When porting code from C++98 to C++11, I ran into a problem: #include <iostream> #include <vector> struct A { ... std::vector<A>(5); } This code should output 122222, and outputs 11111. Why is this happening, and how to fix it?

stl: time spent for adding elements to a vector

Please explain where the legs can grow in time costs when working with the addition to the vector: There are the following da ... e else do not occur, then why add empty ones !!! chains for which only 2 reserve() are called for each spending so much time?

Vector pairs in C++

Hello, I need a vector, each element of which stores a pair of integers.Here is my code: vector <pair<int,int> > ... equest for member "push_back" in "g" which is of non-class type " std::vector > 2000". Please tell me, what is my mistake?

Passing a string vector to a function

You need to move vector<string> from one function to another function and work with it there. I was able to do this wi ... that I have an error in my code, I just want to understand the essence of how to pass the contents of a vector to a function.

Differences, how vector::reserve() and vector::capacity work()

I am writing an implementation of the vector container for myself. And I can't understand how it works and what the vector::capacity() and vector::reserve () methods do in general. I read the documentation, but I don't understand anything.

Push back implementation for a vector

I need to write an implementation of push_back for a vector. But I do not know how to do it correctly. template <typename ... // Не забыть обновить mCapacity = mCapacity*2 mCapacity = capacity; } mVector[mSize++] = value; }

how do I pass a multidimensional vector to a function?

There is a two-dimensional vector of the form vector <vector<int>> vi (n, vector<int>(m, 0)); How can I pass it to a function, for example, by reference?

I can't add a smart pointer to the vector

There is a class MyClass, of course, with a constructor, you need to create a vector of smart pointers to objects of this cla ... nique_ptr<MyClass> p1(new MyClass); // до этого момента всё в порядке vectorPtr.push_back(p1); return 0; }

The difference between push back and emplace back

Tell me, what is the difference between the good old vector::push_back() and the new standard vector::emplace_back()?

Which is faster: vector traversal or list traversal?

At the interview, they asked: which is faster, traversing a vector or traversing a list with values output to the console? Ho ... thing to do with the first? If the entire vector or list does not get into the cache, will the container crawl time increase?

What does for(int x: vector) mean?)

I recently studied c++ from Stroustrup's book , and got to the vectors, here is an example of the code for passing through al ... ,4,6,8 }; for (int x : v) cout << x << endl; But I don't understand what this condition does:for(int x : v)

Is it possible to subtract a vector from a vector?

I do not know, I do not understand just how to implement this task. Develop a complete program in which, using the appropria ... "; cout << endl << endl; system ("pause"); return 0; } Please help me, give me an idea, thank you.