I have been working on what I thought would just be a simple function for quite a while now. We are expected to use push_back()
, but I haven't been able to get it to work.
Here's what I have right now:
void append(const vector<int>& v1, vector<int> v2)
{
for (int x : v1)
v2.push_back(x);
}
void println(const vector<int>& v)
{
for (int x : v)
cout << x << ' ';
cout << endl;
}
int main()
{
vector <int> v1(3, 15);
vector <int> v2(3, 25);
append(v1, v2);
println(v1);
println(v2);
}