可能重複: Which kind of pointer do I use when? ,我讀了std::auto_ptr是過時的,因此必須使用std::tr1::shared_ptr代替。因爲我讀的差異是std::tr1::shared_ptr有引用計數,而std::auto_ptr還沒有,所以複製或分配使資源更改它的所有者,與源給所有權到目的地。這是唯一的區別嗎?
我需要使用RAII成語,我在做正確的事:? std::auto_ptr<std::vector<string>> MyFunction1()
{
std::auto_ptr<std::vector<string>> arrayOfStrings;
MyFunction2(arrayOfStrings); // work with arrayOfStrings
r
我想在我的代碼中使用auto_ptr,但顯然出現了問題。 auto_ptr<ClassType> Class(s.Build(aFilename)); //Instantiation of the Class object
int vM = s.GetM(Class);
int vS = s.Draw(Class);
奇怪的是,類的實例化後,Class對象存在,因此 通過調用s.GetMo