a container with pointers on stucts

Hello all
I have a serious problem. I have constuct the Rl struct with containers and strings.
I whant to make a new constructor with holding Rl pointers, not Rl objects that i already did.
Using code i have error. Any idea?

1
2
3
4
5
6
7
8
typedef vector <Rl> *RLs;
....
RLs monv;
wchar_t * a1=L"a hell please ..."; // ok
Rl *a1= new Rl(a1);  // ok
monv.push_back(&a1); // error 
or ...
monv.push_back(a1); // error  


request for member `push_back' in `monv', which is of non-class type `std::vector<Rl, std::allocator<Rl> >*'


Last edited on
Can you be clearer in your question please. I'm not clear on what you're asking.
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
typedef vector<rR> rRl; //  rR container 

struct rR
{
rR(wstring);
rR();
wstring astring;
};

struct Rl
{
rRl r;
wstring l;
Rl(wstring aString){
r.push_back(rR(aString)) ;
l=	aString;
}
};

now i whant a container of points in struct Rl.
I am truing 
typedef vector <Rl> *RLs;
RLs aR;
wchar_t*a1=L"i am try to do this ...";
Rl *a2= new Rl(a1);
aR->push_back(a2); // here is the error 


If i try with no pointers, but objects all are ok...
Any idea?
If it's just syntax, then the last should be: aR->push_back(*a2); as your vectors has copies of objects.

I'm still not sure what you're asking.
vector <Rl> *RLs; is a pointer to a vector of objects
you need a vector < Rl* > Rls;
Thank's
The right syntax is
typedef vector<rR*> rRl;
...
and then

1
2
3
4
RLs aR;
wchar_t*a1=L"i am try to do this ...";
Rl *a2= new Rl(a1);
aR.push_back(a2);


It works fine and thank's
Thank you for the help.





Topic archived. No new replies allowed.