error in vector<boost::shared_ptr<>>
Dec 1, 2010 at 6:54am UTC
Hi, I am trying to use vector to contain a list of shared pointer of class objects. but I a got compilation error "cannot convert parameter 1 from 'boost::scoped_ptr<T>' to 'const ".
Anyone can help me? thanks
below is my code:
main.cpp
-----------------
1 2 3
std::vector< boost::shared_ptr<CJobInfo> > cadJobList_b;
cadJobList_b.reserve(200);
dao->QueryJobs_b(cadJobList_b,pSQL1.c_str(), cdstart,cdend);
DAO.h
--------------
short int QueryJobs_b(std::vector< boost::shared_ptr<CJobInfo> > &, const char *, const char *, const char * cdtsEnd =" " );
DAO.cpp
-------------
1 2 3 4 5 6 7
short int ReconDAO::QueryJobs_b(std::vector< boost::shared_ptr<CJobInfo> >& jbList, const char * psq, const char * cdtsStart, const char * cdtsEnd )
{
boost::scoped_ptr<CJobInfo> prec(new CJobInfo);
prec->_amount= l_TableQuery.GetDouble(8);....
jbList.push_back(prec);
}
error C2664: 'std::vector<_Ty>::push_back' :
cannot convert parameter 1 from 'boost::scoped_ptr<T>' to 'const boost::shared_ptr<T> &'
Last edited on Dec 1, 2010 at 7:22am UTC
Dec 1, 2010 at 7:31am UTC
sorry type error. should be
boost::shared_ptr<CJobInfo> prec(new CJobInfo);
Dec 1, 2010 at 9:06am UTC
If this fixed your problem, you should mark this thread as solved.
Topic archived. No new replies allowed.