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

Please help fill in the code to implement an array class for characters. /* Comm

ID: 3878991 • Letter: P

Question

Please help fill in the code to implement an array class for characters. /* Comments help to know what to do in each function. Needs to be in C++

/**

* Retrieve the current size of the array.

* @return The current size

*/

size_t size (void) const;

/**

* Retrieve the maximum size of the array.

* @return The maximum size

*/

size_t max_size (void) const;

/**

* Get the character at the specified index. If the index is not

* within the range of the array, then std::out_of_range exception

* is thrown.

* @param[in] index Zero-based location

* @exception std::out_of_range Invalid  index value

*/

char & operator [] (size_t index);

/**

* @overload

* The returned character is not modifiable.

*/

const char & operator [] (size_t index) const;

/**

* Get the character at the specified index. If the  index is not within

* the range of the array, then std::out_of_range exception is thrown.

* @param[in] index Zero-based location

* @return Character at index

* @exception std::out_of_range Invalid index value

*/

char get (size_t index) const;

/**

* Set the character at the specified  index. If the  index is not

* within range of the array, then std::out_of_range exception is

* thrown.

* @param[in] index Zero-based location

* @param[in] value New value for character

* @exception std::out_of_range Invalid  index value

*/

void set (size_t index, char value);

Explanation / Answer

Implementation:

size_t size (void) const {

return strlen(char const *s);

}

size_t max_size (void) const {

//65792 bytes

return 65792;

}

char & operator [] (size_t index) {

if (str.get(index) != null) {

return str.get(index);

}

else {

throw std::out_of_range ("character not found at given index.");

}

}

const char & operator [] (size_t index) const {

return const char;

}

char get (size_t index) const {

if (str.get(index) != null) {

return str.get(index);

}

else {

throw std::out_of_range ("character not found at given index.");

}

}

void set (size_t index, char value) {

if (index >= 0 && index < sizeof(arr)) {

str.set(index, value);

}

else {

throw std::out_of_range ("character cannot be set at given index.");

}

}

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