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!
boost::ptr_list::front()returns a reference to the templated type, not a pointer.So in this case it’s returning a
basic_action&.See the documentation here for
ptr_sequence_adapter, from whichptr_listis derived.So your code should read: