This is the code I have that causes the error below:
class CAlternateMerchantList
{
public:
CAlternateMerchant::SP m_pAlternateMerchantList[MAX_PLAYER_LIST];
int m_nMax;
int m_nCur;
CAlternateMerchantList()
{
int i;
for (i = 0; i < MAX_PLAYER_LIST; i++)
m_pAlternateMerchantList[i] = NULL;
m_nMax = 0;
m_nCur = 0;
}
The error I get is the following:
PersonalShop.h: In constructor ‘CAlternateMerchantList::CAlternateMerchantList()’:
PersonalShop.h:227: error: no match for ‘operator=’ in ‘((CAlternateMerchantList*)this)->CAlternateMerchantList::m_pAlternateMerchantList[i] = 0’
/usr/local/include/boost-1_65_1/boost/smart_ptr/shared_ptr.hpp:547: note: candidates are: boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<T>&) [with T = CAlternateMerchant]
As you can see, I'm using boost 1_65_1
libraries. If I am not wrong, this code worked on another system with boost 1_59
, but at the moment I can not access it for testing.
Does anyone know how to make this code work with boost 1.65? Or, is there any other issue here?
You don't need to set boost::shared_ptr
s to null. They have a default constructor which does it automatically. You can simply delete the entire for
loop.
I suggest also using an initialization list for m_nMax
and m_nCur
.
CAlternateMerchantList()
: m_nMax(0), m_nCur(0)
{
}