- 64
- 0
- 约4.51千字
- 约 10页
- 2018-11-10 发布于天津
- 举报
1.2关于类定义格式的描述中,()是错误的。A、必须以关
#include iostream.h const int maxcard=20; class Set { int elems [maxcard]; int card; public: Set (void){card=0;}; void print(); friend bool operator (int, Set); friend Set operator + (Set, int); friend Set operator + (Set, Set); }; bool operator(int elem, Set s) //判断元素elem是否属于集合s { for(int i=0; is.card ; i++) if(s.elems[i]==elem) return true; return false; } Set operator+(Set s,int elem) //把整数elem加入到集s中,如s已满就不加入 { Set res=s; if( s.cardmaxcard ) if(!(elems)) res.elems[res.card++]=elem; return res; } Set operator+(S
原创力文档

文档评论(0)