Question: Use loop, stack, and recursion to reverse the string. It confuses me for a long time, thank you so much! #ifndef SMARTREVERSE_H #define SMARTREVERSE_H #include

Use loop, stack, and recursion to reverse the string.

It confuses me for a long time, thank you so much!

#ifndef SMARTREVERSE_H #define SMARTREVERSE_H #include using namespace std; class smartReverse { public: // default constructor smartReverse(); // constructor: initialize str with ini_str passing as a parameter smartReverse(string ini_str); // return the current value of the private data member: str string getString() const; // set the value of str to be the passed in parameter input_str void setString(string input_str); // return a reversed string // using a loop to implement // Note that str has not been changed string rev() const; // return a reversed string // using recursion to implement // Note that str has not been changed string rev_recursive() const; // return a reversed string // using a stack to implement // Note that str has not been changed string rev_stack() const; private: string str; }; #endif /* SMARTREVERSE_H */

||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

#include #include "smartReverse.h" // default constructor smartReverse::smartReverse() { // you do not really need to do anything // since string class provides default constructor // to initialize the object to empty string } // constructor: initialize str with ini_str passing as a parameter smartReverse::smartReverse(string ini_str)

{ } // return the current value of the private data member: str string smartReverse::getString() const { } // set the value of str to be the passed in parameter input_str void smartReverse::setString(string input_str) { }

// return a reversed string from str // using a loop to implement // Note that str has not been changed string smartReverse::rev() const { } // return a reversed string from str // using recursion to implement // Note that str has not been changed string smartReverse::rev_recursive() const

{ } // return a reversed string from str // using a stack to implement // Note that str has not been changed string smartReverse::rev_stack() const { }

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!