Point out structs vectors

Hi guys,

I defined an structure like this,

struct STRUCT1
{
bool bvar;
std::string svar;
};

And then five vectors of this last struct (STRUCT1),

std::vector <STRUCT1> first_vector_structs;
std::vector <STRUCT1> second_vector_structs;
std::vector <STRUCT1> third_vector_structs;
std::vector <STRUCT1> fourth_vector_structs;
std::vector <STRUCT1> fifth_vector_structs;

Finally (and I'm not sure of its correctness), I defined a pointer

std::vector <STRUCT1> * struct_pointer;

To point out one of the above five vectors. I made,

struct_pointer = & first_vector_structs;

(Is it OK?)

But here the problem goes when I try to access the nodes values by the structs vector "struct_pointer"...

How could I do to point an specific node, using the vector pointer ?

Alternatively... Do you know a better solution to point out these five vectors ?

Sever
You mean like this?
1
2
(*struct_pointer)[index].bvar
struct_pointer->at(index).svar
Last edited on
1
2
( *struct_pointer )[i].bvar;
( *struct_pointer )[i].svar;


where i is less than struct_pointer->size();
Last edited on
That's it, thanks !!
Topic archived. No new replies allowed.