c++ 运算符重载-集合运算(国外英文资料).doc
文本预览下载声明
c++ 运算符重载-集合运算(国外英文资料)
# include iostream. H
H # include math.h
# include iomanip. H
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
Enum errcode {noerr, overflow};
/ / define the collection class
The class set
{
Public:
Void the print (); / / displays the output collection element
Set () {card = 0; }
Virtual ~ the set ();
Errcode additem (int); / / add the set element
Friend bool operator (int, set); / / declare overloading operator , to determine whether an integer belongs to a certain set
Friend bool operator = (set, set). / / declare overloading operator = = to determine whether two sets are equal
Friend Boolean operator! = (set, the set); / / declare overloaded operator! To determine whether two sets are different
Friend set operator * (set). / / declare overloading operator *, for the intersection of two sets
Friend set operator + (set). / / declare overloading operator +, and ask for the sum of two sets
Friend bool operator (set) / / declare overloading operator , to determine whether a set is a pure subset of another set
Friend bool operator = (set, set) / / declare overloading operator =, to determine whether a set is a subset of another set
Private:
Int elems [16].
Int card;
};
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
The concrete definitions of the member functions of the / / collections class
Set: : ~ the set ()
{
}
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/ *
Function name: print
Functional description: display complex Numbers
Modify the record:
* /
Void the set: : print ()
{
Cout ;
For (int I = 0; I car-1; I + +)
Cout
If (card 0)
Cout
}
/ * * * * * * * * *
显示全部