C
cleerline
Hi there,
I have the following code:
in .h file i have
class myclass
{
....
....
tile_list* my_tile_list;
....
....
}
in .cpp file I have
....
....
my_tile_list = new tile_list(a, b);
....
....
Now, i am trying to replace the pointers to tile_list with a smart
point (specificly the boost shared_ptr smart pointer)
Now, in the docs it says "replace all occurrances of new with
shared_ptr<T> p(new Y)
Now, I can do this when I have somthing like:
tile_list* x = new tile_list(a, b);
it becomes:
shared_ptr<tile_list> p(new tile_list(a,b));
it compiles and all is well.
HOWEVER, how do i do the same thing for the pointers which are member
variables?
They are declared and instantiated in different places.
I have tried the following:
class myclass
{
....
....
shared_ptr<tile_list> p;
....
....
}
in .cpp file I have
....
....
shared_ptr<tile_list> p(new tile_list(a,b));
....
....
but this does not work.
How do I do this??
thanks for any help.
Cleerline
I have the following code:
in .h file i have
class myclass
{
....
....
tile_list* my_tile_list;
....
....
}
in .cpp file I have
....
....
my_tile_list = new tile_list(a, b);
....
....
Now, i am trying to replace the pointers to tile_list with a smart
point (specificly the boost shared_ptr smart pointer)
Now, in the docs it says "replace all occurrances of new with
shared_ptr<T> p(new Y)
Now, I can do this when I have somthing like:
tile_list* x = new tile_list(a, b);
it becomes:
shared_ptr<tile_list> p(new tile_list(a,b));
it compiles and all is well.
HOWEVER, how do i do the same thing for the pointers which are member
variables?
They are declared and instantiated in different places.
I have tried the following:
class myclass
{
....
....
shared_ptr<tile_list> p;
....
....
}
in .cpp file I have
....
....
shared_ptr<tile_list> p(new tile_list(a,b));
....
....
but this does not work.
How do I do this??
thanks for any help.
Cleerline