

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: ALGS/DATA STRUCTURES; Subject: COMPUTER SCIENCE; University: Clemson University; Term: Unknown 1989;
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CpSc 212—Goddard—SummerI 09
(b) Gives bar access to the private parts of Foo (c) Copying a huge parameter is wasterful. (d) char[] name = "Goddard";
b) c) d)
MyInteger ( int v ) : val(v) {} // value must be set in initializer
bool operator==( const MyInteger & oo ) { return val == oo.val; }
MyInteger operator+( const MyInteger & oo ) { return MyInteger( val + oo.val ); }
DBag( const DBag &other) : count( other.count), A(new double[MAX_COUNT]) { for(int i=0; i<count; i++) A[i] = other.A[i]; }
void delete(double item) { for(int i=0; i<count; i++) if( item==A[i] ) { A[i]=A[count-1]; count--; return; } }
ostream &operator<< (ostream &out, const DBag &myDBag) { for(int i=0; i<myDBag.count-1; i++) out << myDBag.A[i]+":"; out << myDBag.A[myDBag.count-1]; return out; }