Question: Note: Please Do the following Program in CPP Programming Language: Write a class that takes a C string as an input parameter and reverses the

Note: Please Do the following Program in CPP Programming Language:

Write a class that takes a C string as an input parameter and reverses the string. Your code should be divided into a strReverse.h file, a strReverse.cpp file and a main.cpp file. The main.cpp should get a c-string (either from the keyboard or hard coded, your choice), instantiate the strReverse class, use a setter to place the inputted string into a member variable.

The strReverse class should contain a function to reverse the string IN PLACE and an appropriate output function. In place means, you should reverse the string in its existing memory space, you cant copy it to a new string or use any library function to reverse it.

The intention here is to use pointers to reverse the string.

The function should use two pointers, front and rear.

The front pointer should initially reference the first character in the string, and the rear pointer should initially reference the last character in the string.

NOTE: You should loop through the string to find the null character to determine the length of the string.

Reverse the string by swapping the characters referenced by front and rear, then increment front to point to the next character and decrement rear to point to the preceding character, and so on, until the entire string is reversed.

You should test your function on various strings of both even and odd length. If you are reading from keyboard, be sure to test it with strings that contain a space.

Example is Given Below:

Note: Please Do the following Program in CPP Programming Language: Write a

front rear Swap characters pointed at by front and rear G S TR N A 0 front rear Increment front, decrement rear G S T R N A 0 front rear

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!