Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions