Vector of pointer within Vector Pointer

Write your question here.

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
33
34
35
36
37
38
39
40
41
42
43
 Hi everyone i just want to know for sure if u can do a Vector of pointer within a Vector pointer, example( std::vector<std::<int*> >* zz ).

Cuz i can do the push backs(push_back) to enter data into the vector but no matter how much i try i cant later access the the data in the code.
So i'll show u the pieces in my code that's not working in my class code.

Down below you will see the concept i'm after. Not sure if it possible or i'm just slightly off from getting it or i'm going at it totally wrong.

[code]
  Put the code you need help with here.

// the header file which contains a class

class terrain
{
public:

void raw();

std::vector< int* > gri;	
std::vector< std::vector< int*> >* gridi = new std::vector<std::vector< double*> > ;
};
#endif


// Then in a cpp file.

void terrain::raw()
{
  int p=20;

  int* t= new int;
  t=&p;
  gri.push_back(t);

 (*gridi).push_back(gri); // So good so far ..no errors yet

//the part below is where i'm trying to access the data stored with no luck.
 std::cout<<"the value is: "<<(*gridi)[0].gri[0]<<"\n";

// The part above is the source of my contention please is what i'm attempting possible or am i doing it WRONG. Please if u know the precise way please do share.

}
> i just want to know for sure if u can do a Vector of pointer within a Vector pointer,
> example( std::vector< std::vector<int*> >* zz )

Yes, but it would almost certainly be the wrong thing to use.
Strongly consider using value semantics (no pointers): std::vector< std::vector<int> > vec2d
Topic archived. No new replies allowed.