I have a class:
//header file
class CMDatabase
{
class Try;
typedef boost::shared_ptr TryPtr;
typedef boost::ptr_vector TryVect
The issue is that your equal
method is not const
qualified.
class Try
{
public:
virtual ~Try();
virtual bool equal(CMDatabase::TryPtr const& mySd) const = 0;
};
bool TryImpl::equal(CMDatabase::TryPtr const& mySd) const { return true; }
Note:
const
added to the method, otherwise it cannot be used on const
objectsconst
added on the pointer: copying shared_ptr
does cost, because it necessitates incremented a shared counter, and decrementing it afterward.EDIT:
Reminder for the unwary: the Pointer Container library has been designed so that the interface would be as easy to use a possible, and one of the goody is that you don't have to double dereference. This compiles:
boost::ptr_vector vec;
vec.push_back(new int(3));
int& i = *vec.begin();
Thus, your functor must take a reference, not a pointer :)