Trying to obtain 3D vector with multiple 2D vectors

Hello fellows. I am trying to push_back 2D matrices I obtained from ontain function and I need to have 3D vector by adding these 2D vectors. TO do so, I coded as follows but I could not achieve it. 3D1.push_back and 3D2.push_back are underlined in main function. I will be very happy if you can help me to fix it.
Thank you so much
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
std::tuple<std::vector<vector<int>>, std::vector<std::vector<int>>> obtain();

int main()
{
   std::tuple<std::vector<std::vector<int>>,  std::vector<std::vector<int>>> c;
    vector<vector<vector<int>>>3D1;
    vector<vector<vector<int>>>3D2;
	
		for (int kk=0; kk<3;kk++)
	{
	
		c = obtain();	
		3D1.push_back(get<0>(c));
		3D2.push_back(get<1>(c));
	}
   
}

std::tuple<std::vector<int>, double, std::vector<std::vector<int>>> obtain()
{
   std::vector<std::vector<int>> v2d1 {{ 6, 7, 13 },{ 2, 4, 6 } };

   std::vector<std::vector<int>> v2d2  { { 1, 3, 5 }, { 2, 4, 6 } };

   return std::make_tuple(v2d1, v2d2);
}

Last edited on
You have conflicting definitions of obtain().
For brevity, I will abbreviate:
tuple --> T
vector<int> -> VI
vector<vector<int>> --> VVI

Line 3: obtain shall return a T<VVI, VVI>
Line 9: c is a T<VI, double, VVI>
Line 16: type(c) != type(obtain())
Line 23: obtain shall return a T<VI, double, VVI>
Line 24: You are making a T<VVI, VVI>
Thank you @Ganado, it was copy-paste mistake. It has been corrected now
Oh, you're gonna laugh. You can't start a variable name with a number :)
Last edited on
@Ganado. Thanks you so much :) It is really funny :) I could not see it sorry , thank you so much
Topic archived. No new replies allowed.