喜IM存儲一個矢量對象共享指針和調用打印過程打印出來,但它拋出一個錯誤,因爲「敵不過呼叫**」下面是代碼將共享指針存儲矢量對象拋出錯誤?
namespace info
{
typedef struct {
std::string Yes;
std::string NO;
int ID_NO;
} mystruct;
typedef std::vector<mystruct> myvector;
typedef struct {
bool status;
std::shared_ptr<myvector> shared;
} Myreturn;
}
void printmyinfo(const std::shared_ptr<info::mystruct>& printval)
{
if(printval == NULL)
{
cout<<"Sorry no value exist"<<endl;
return;
}
// here is print code which is good.
}
int main()
{
info::mystruct *structinfo=new mystruct ;
structinfo->yes="okay";
structinfo->ID_NO=10;
info::myvector vectorobject;
vectorobject.push_back(structinfo);
info::Myreturn *returnobj=new Myreturn;
returnobj->shared(myvector)// bad how to store vector in share pointer of Myreturn structure
//如何用myvector填充Myreturn.shared並傳遞給printmyinfo? printmyinfo(myvector)//壞 }
在這一行returnobj.shared(structinfo)
錯誤thow請幫我解決它感謝
如何填寫Myreturn.shared與myvector,並傳遞給printmyinfo?
對不起我的錯誤是在堆不是堆疊。 – pravakar