The following operation is part of a cash register machine.
In order to generate a bill I should count the products:
1. Each product is added once to the bill.
2. In case the product is already exist in this bill, its quantity is incremented.
void CashRegister::countProducts()
{
OMIterator<Product*> iter(itsProduct);
CountedProduct* cp;
Product* p;
// Iterate through all products counting them
while (*iter) {
  // get the next product
  p = *iter;
  // has this already been added?
  cp = getItsCountedProduct(p->getBarcode());
  // If it does not exist then add it else increment it
  if (NULL==cp) {
    addItsCountedProduct(p->getBarcode(), new CountedProduct(p));
  } else {                                                       
    cp->increment();
  }                 
  // point to next
  ++iter;
}    
and:
void CashRegister::addItsCountedProduct(int key, CountedProduct* p_CountedProduct) 
{
if(p_CountedProduct != NULL)
    {
        NOTIFY_RELATION_ITEM_ADDED("itsCountedProduct", p_CountedProduct, false, false);
    }
else
    {
        NOTIFY_RELATION_CLEARED("itsCountedProduct");
    }
itsCountedProduct.add(key,p_CountedProduct);
}
I get the following error:
error C2664: 'CountedProduct::CountedProduct' : cannot convert parameter 1 from 'Product *' to 'const CountedProduct &' 
The error is references to this line:
addItsCountedProduct(p->getBarcode(), new CountedProduct(p));
Any ideas?
 
     
    