Boost logo

Boost Users :

From: Drew (drewtenn_at_[hidden])
Date: 2003-06-19 10:38:18


[Moderator's note: The only apparent connection this message has to Boost is in the subject line. I am approving it on the assumption that the missing declarations for ParentPtr and DerivedPtr are typedefs using boost::shared_ptr.]

Hello everyone...

I am attempting to do the following:

class Parent
{
public:
  int m_value;
};

class Derived : public Parent
{
};

void Fn(ParentPtr& pObj)
{
  pObj = ParentPtr(new Parent());
  pObj->m_value = 10;
}

int main()
{
  ParentPtr pParent;
  DerivedPtr pDerived;

  Fn(pDerived);

  return 0;
}

If I pass the parent pointer, it compiles and works fine. If I pass
the derived pointer I get:

error C2664: 'Fn' : cannot convert parameter 1 from 'DerivedPtr'
to 'ParentPtr &'

Does anyone know how to solve my problem?

TIA,
Drew


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net