算法的正确性和有效性 Algorithms Correct&Efficiency COMP2009

这是一份nottingham诺丁汉大学COMP2009作业代写的成功案例

算法的正确性和有效性 Algorithms Correct&Efficiency COMP2009



SmartPtr<something $>$ spl, sp2;
Something* $\mathrm{p}$;
if (spl) // Test 1: direct test for non-nul1 pointer
if (spl) // Test $1:$ direct test for non-null pointer if $($ !sp1) // Test $2:$ direct test for null pointer
if $(! \operatorname{sp} 1) \quad / /$ Test $2:$ direct test for null pointer $\cdots \cdot$ if $(\operatorname{sp} 1=0) \quad / /$ Test 3 : explicit test for null pointer
$\cdots$
if $(\mathrm{sp} 1==\mathrm{sp} 2) / /$ Test 4 : comparison of two smart pointers
$\cdots$
if $(\operatorname{sp} 1==p) \quad / /$ Test 5 : comparison with a raw pointer
$\cdots$
英国论文代写Viking Essay为您提供作业代写代考服务

COMP2009 COURSE NOTES :

$\mathrm{~ t e m p l a t e ~ 〈 c l a s s ~ T}$
class SmartPtr
f
public:
bool operator! () const // Enables "if (!sp) ..."
f
return pointee_ $==0$;
\}
inline friend bool operator==(const SmartPtr\& lhs,
const $T^{*}$ rhs)
$f$
return lhs.pointee_ $==$ rhs;
?
inline friend bool operator==(const $T^{*}$ lhs,
const SmartPtr\& rhs)
1
return lhs $==$ rhs pointee_;
\}
inline friend bool operator!=(const SmartPtr\& lhs,
const $T^{*} r h s$ )
$f$
return lhs.pointee_ I= rhs;
\}
inline friend bool operator!=(const $T^{*}$ lhs,
const SmartPtr\& rhs)
$\uparrow$









发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注