單鏈表(
下面將完成單鏈表的賦值運算的重載
operator = (const List<Type> &l)
{
MakeEmpty();
for (Node<Type> *p = l
}
還記得List類的private裡面的這個List(const List<Type> &l)嗎?當初怕它惹禍
List(const List<Type> &l)
{
first = current = last = new Node<Type>; prior = NULL;
for (Node<Type> *p = l
}
終於可以這樣寫了a = b + c * d
friend Polynomial operator + (Polynomial &polyA
{
Polynomial tempA = polyA;Polynomial tempB = polyB;
PolyAdd(tempA
return tempA;
}
friend Polynomial operator * (Polynomial &polyA
{
Node<Term> *pA = polyA
Node<Term> *pB = polyB
Polynomial polyTempA
int coef
if (pA == NULL || pB == NULL) return polyTempA;
for (pA = polyA
{
for(pB = polyB
{
coef = pA
exp = pA
Term term(coef
polyTempB
}
PolyAdd(polyTempA
polyTempB
}
return polyTempA;
}
【後記】很顯然
From:http://tw.wingwit.com/Article/program/sjjg/201311/22942.html