Framework was being overly literal. The only way to do any two things simultaneously is with threads. But I'm sure you weren't talking about being truly simultaneous.
If you use an array rather than different named items, you can push_back all of them in a loop:
1 2 3 4
vector<double> group[3];
for(int i = 0; i < 3; ++i)
group[i].push_back( whatever ); // pushes a value into all vectors
Although... you probably should not try to keep multiple vectors in sync. It might be best to combine the data into a struct, then have a vector of that struct:
Thanks for your reply. Based on this, I would like to ask a question a bit more complicated. If I have several array with same number of elements, like
1 2 3
double a[10] = {1.0, 2.0, // assign values...}
double b[10] = {1.1, 2.1, // assign values...}
// other similar arrays...
I want to store them in a big object, with corresponding relationship E[0] = {a[0], b[0], ...}; E[1] = {a[1], b[1], ...}; E[2] = {a[2], b[2], ...}; ... like an Excel data table. Then I can sort the order of E[0], E[1], E[2], ... according to the value of a, or the value of b, or other elements.
I think there is no native and easy way to do that.
I think there are two ways:
1. Search for an libary which includes a function which implements the algorithm (Maybe #include <algorithm> ? )
2. Implement it yourself
#include <iostream>
#include <functional>
#include <vector>
struct A
{
std::vector<int> a;
std::vector<int> b;
std::vector<int> c;
A()
{
std::vector<std::reference_wrapper<std::vector<int>>> rv = { a, b, c };
for ( auto x : rv )
{
for ( int i = 0; i < 10; i++ ) x.get().push_back( i );
}
}
};
int main()
{
A a;
for ( auto x : a.a ) std::cout << x << ' ';
std::cout << std::endl;
for ( auto x : a.b ) std::cout << x << ' ';
std::cout << std::endl;
for ( auto x : a.c ) std::cout << x << ' ';
std::cout << std::endl;
return 0;
}