/* Note: this program has buggy code. It is suppsoed to demonstrate why we need to have a copy constructor and an overloaded assignment operator. */ #include using namespace std ; #include "myArray.h" int main() { myArray A ; for (int i = 0 ; i < 5 ; i++) { A.append(i) ; } A.data[2] = 777 ; cout << "A = " ; A.print() ; myArray B(10) ; // Buggy! B = A.slice(1, 4) ; cerr << "After calling slice\n" ; B.data[1] = 2 ; cout << "B = " ; B.print() ; cout << "A = " ; A.print() ; }