2013-08-24 46 views
1

我在這段代碼中收到以下錯誤。C2248 - 在將QScopedPointer傳遞給函數時無法訪問私有成員

QScopedPointer<NoteEvent> onEvent(new NoteEvent(date, chan, pitch, vel, true)); 
QScopedPointer<NoteEvent> offEvent(new NoteEvent(date + dur, chan, pitch, vel, false)); 
Score::noteStream->addNoteEvent(onEvent); 
Score::noteStream->addNoteEvent(offEvent); 


void NoteStream::addNoteEvent(QScopedPointer<NoteEvent> noteEvent) 
{ 
    noteEvents->push_back(noteEvent); 
} 

錯誤:C2248: 「QScopedPointer」:沒有獲得在QScopedPointer

通過其他職位閱讀聲明爲private成員是沒有幫助的。

回答

4

QScopedPointer沒有公共拷貝構造函數。它不能按價值傳遞,也不能存儲在要求其元素可複製的容器中(取決於它的聲明方式,這可能是noteEvents)。

+1

使用SharedPointer似乎是一個合適的替代方案 – user2052244

相關問題