我有做這樣的功能:通行證指針auto_ptr的用C++
static MyClass* MyFunction(myparams)
{
return new MyClass(myparams)
}
和我將能夠調用內另一個具有以下簽名此功能:
void MyFunction2(std::auto_ptr<MyClass> myparam)
但當我嘗試這樣做時,我有一個編譯器錯誤:
Impossible to convert the first param from MyClass * to std::auto_ptr<_Ty>
爲什麼?感謝您的幫助
編輯1 至於問myparams類型是正常的,但也有一件T PARAM因爲函數是一個模板類
MyFunction中myparams的類型是什麼,它在問題中缺失。 – 2011-02-10 18:16:27
你瞭解`auto_ptr`的用途嗎? – Cascabel 2011-02-10 18:18:21