Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is a C++ class definition for an abstract datatype Sequence of string s,rep

ID: 3616121 • Letter: H

Question

Here is a C++ class definition for an abstract datatype Sequence of strings,representing the concept of, well, a sequence of strings. When wetalk about the position of an item in the sequence, we start atposition zero. For example, in the three-itemsequence "lavash" "tortilla" "injera", the stringat position 1 is "tortilla".

Here's an example ofthe swap function:

Notice that the empty string is just as good a string as anyother; it should not be treated in any special way:

When comparing itemsfor remove, find, and theone-parameter insert, just use the comparisonoperators provided for the string type by the library: <, <=,==, etc. These do case-sensitive comparisons, and that's fine.




Determine which member functions of the Sequence classshould be const member functions (because they do not modify theSequence), and change the class declarationaccordingly.

2) As defined above, the Sequence classallows the client to use a sequence that containsonly strings.Someone who wanted to modify the class to contain items of anothertype, such asonly ints oronly doubles,would have to make changes in many places. Modify the classdefinition you produced in the previous problem to usea typedef-definedtype for all values wherever the original definition useda string.Here's an example of a useof typedef:

To modify this code to sum a sequenceof longs orof doubles, weneed make a change in only one place: the typedef.

You may find the exampleusing typedef startingat the bottom of p. 156 of the textbook useful.

To make the grader's life easier, we'll require thateveryone use the same synonym astheir typedef-definedname: You must use thenameItemType, withexactly that spelling and case.

Explanation / Answer

For this question the methods that can be const are: empty() Which returns whether or not this list is empty size() returns the size of the array get() gets a point in the sequence if it exists find() searches for a value in the sequence. Now part two is easy. Just add typedef int NUMBER and you just run a find replace int with NUMBER. After thatyou can change typedef int NUMBER to typedef double NUMBER if youwanted to.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote