Question: I have got a virtual class `basic_action`. Class `sippeers` inherits class `basic_action`. To store instances of `sippeers` classes I'm using `boost::ptr_list`. Here's code example:

```
boost::ptr_list<basic_action> ActionsList;
sippeers spclass;
ActionsList.push_back(&spclass);
basic_action *sp = ActionsList.front();

```

Here I create an instance of `prt_list` with pointers to instances of my `basic_action` classes.
Next I make new instance of my `sippeers` class.
Next I insert pointer to `sippeers` class into `ptr_list`.

The last string fails. 

> 
> Cannot convert from 'basic\_action' to
>  'basic\_action \*'.
> 
> 
> 

But there IS a `basic_action *` inside, not `basic_action`!

Answer: 
ptr\_list::front() returns a reference to the first object in the list.
If basic\_action was a concrete type you could both of the following.

```
// 1
basic_action& sp = ActionsList.front();

// 2
basic_action sp = ActionsList.front();

```

#1 would make sp a reference to the first object in the list. In other words, any changes you made through sp would also change the first object in the list.

#2 would instantiate a new basic\_action object and copy the contents of the first object in the list into this new object. Any changes to it would not affect the first item in the list.

If basic\_action is an abstract class option #2 is no longer available to you because you cannot instantiate abstract class objects.

also, you shouldn't put stack allocated objects into a boost pointer container. Bad things will happen when the ptr\_list goes out of scope and tries to delete all the objects it contains. Instead do something like:

```
boost::ptr_list<basic_action> ActionsList;
ActionsList.push_back(new sippeers);
basic_action& sp = ActionsList.front();

```
If you look at the [header](http://www.boost.org/doc/libs/1_46_1/libs/ptr_container/doc/ptr_sequence_adapter.html) then you will see that:

```
template
<
    class T,
    class VoidPtrSeq,
    class CloneAllocator = heap_clone_allocator
>
class ptr_sequence_adapter
{
public: // construct/copy/destroy
    template< class InputIterator >
    assign( InputIterator first, InputIterator last );
    template< class InputRange >
    assign( const InputRange& e );

public: // element access
    T&        front();

```

(Note; ptr\_list directly inherits from ptr\_sequence\_adapter) So you are getting the type, not a reference to the type; it does an automatic dereference for you:

```
basic_action sp = ActionsList.front();

```

is correct.