Sale!

CSCI 335 First assignment solved

Original price was: $35.00.Current price is: $35.00. $17.50

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

The big five
Create and test a class called Chain. A chain is just a series of items, e.g. [2 7 -1 43] is a chain
containing four integers.
The purpose of this assignment is to have you create a vector-like class from scratch, however,
so you may not use vector, list or other classes from the STL here. Please note that chains are
similar in many respects to vectors of items. Unless you get permission from me, don’t include
any libraries except iostream and cstdlib.
Pay special attention to Weiss’s “big five,” the destructor, copy constructor, copy assignment
operator, move constructor and move assignment operator. Include cout statements at the
beginning of the constructors and assignment operators in order to see when these functions
are being called.
When your class is complete, the following code should work, with results as commented.
Insert this piece of code as is in your testing function.
Chain a, b, c; //Three empty chains are created
Chain d{10}; // A chain containing just one element: 10
cout << d; // Output is [ 10 ]
cout << a.Length() << endl; // yields 0
cin >> a; // User types [2 3 7]
cout << a; // Output is [2 3 7]
cin >> b; // User types [8 4 2 1]
c=a; // Copy assignment
cout << c; // Output should be [2 3 7]
cout << a+b << endl; // Output is [2 3 7 8 4 2 1]
cout << a + 5; //Output is [2 3 7 5]
Chain e{c}; //Copy constructor
cout << e; //Output should be [2 3 7]
cout << a[1] << endl; //Should printout 3
c[1]=100; //Should change c
cout << c; //Should print [2 100 7]
cout << e; //Should print [2 3 7]
Chain f = GetChain()}; // GetChain() should be a function that returns by
value a Chain of some elements. Write this simple function.
cout << f; // Should print whatever GetChain() returned.