0
我想引用指針後面的值。引用指針後面的值
class UnicastCall {
protected:
std::fstream *m_stream_attachement_destination_;
...
public:
auto GetStreamAttachementDestination_AsPointer() -> decltype(m_stream_attachement_destination_)
{ return m_stream_attachement_destination_; } //THIS WORKS
auto GetStreamAttachementDestination_AsReference() -> decltype(*m_stream_attachement_destination_) &
{ return *m_stream_attachement_destination_; } //IS THIS CORRECT?
....
};
但我得到一個錯誤。
error: use of deleted function 'std::basic_fstream<_CharT, _Traits>::basic_fstream(const std::basic_fstream<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]'
auto fs = concrete_call->GetStreamAttachementDestination_AsReference();
太棒了!編譯和工作 –