Re: [Boost-users] [smart_ptr] Multiple inheritance problem with smart pointer

Hi All, I'm trying to begin using smart pointers, and when I changed my typedefs like: typedef TimeSeriesClass* pTimeSeries; to typedef boost::shared_ptr<TimeSeriesClass> pTimeSeries; where: class TimeSeriesClass : public wxGridTableBase, public tsObject { (...) } I get an error in this situation: myDataAnalyserFrame::myDataAnalyserFrame( wxWindow* parent , pTimeSeries myTimeSeries) : DataAnalyserFrame( parent ) { m_myTimeSeries = myTimeSeries; m_tsOld = new wxGridStringTable( 1, 1 ); DataGrid->SetTable(m_myTimeSeries ,false); => the m_myTimeSeries, whis is a smart pointer to the TimeSeriesClass, doesn't know that TimeSeriesClass is also wxGridTableBase child? m_myTimeSeries->AutoSizeColsLabels(); DataGrid->Refresh(); } bool SetTable( wxGridTableBase *table, bool takeOwnership = false, wxGrid::wxGridSelectionModes selmode = wxGrid::wxGridSelectCells ); The problem occurs because the smart_pointer to the TimeSeriesClass seems to ignore that TimeSeriesClass is also a wxGridTableBase. With normal pointers it functions. Why it does not work? What i'm doing wrong? Thanks in advance. Best Regards. José Augusto

Hi José,
2010/11/20 José Augusto Jr.
DataGrid->SetTable(m_myTimeSeries ,false); => the m_myTimeSeries, whis is a smart pointer to the TimeSeriesClass, doesn't know that TimeSeriesClass is also wxGridTableBase child?
It looks like you're expecting an implicit conversion from shared_ptr to the underlying pointer type. For various good reasons this isn't an implicit operation -- use the get() method to obtain the underlying pointer: DataGrid->SetTable(m_myTimeSeries.get(), false); HTH, Nate
participants (2)
-
José Augusto Jr.
-
Nathan Crookston