来问一个关于smart pointer的弱问题# JobHunting - 待字闺中
r*c
1 楼
大家都是大牛,菜鸟来问一个弱问题。
Smart pointer implementation里, dereferencing operator 和 member selection
operators是这样定义的。
T& operator* () const // dereferencing operator
{
return *(m_pRawPointer);
}
T* operator->() const // member selection operator
{
return m_pRowPointer;
}
想知道,因为什么,前者returned by reference, 后者 returned by pointer呢?能
不能前者return-by-pointer, 后者return-by-reference呢?
Smart pointer implementation里, dereferencing operator 和 member selection
operators是这样定义的。
T& operator* () const // dereferencing operator
{
return *(m_pRawPointer);
}
T* operator->() const // member selection operator
{
return m_pRowPointer;
}
想知道,因为什么,前者returned by reference, 后者 returned by pointer呢?能
不能前者return-by-pointer, 后者return-by-reference呢?