codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Help with recursion { recursive helper function }  mibit at 17:44 on Friday, May 16, 2008
 


Can you please help me with the source code solving this task under C++/G++ (linux) or dev C++ (windows)

[img]http://mail.dir.bg/~storage/cPlus_plus111.jpg[/img]

Below you can see a hint for solving Exercise P14.1 but I need to write the source for [color=red]Exercise P14.1 P[/color]lease help me

http://www.horstmann.com/bigcpp/solutions/ch14/ExP14_1.cpp

#include <string>

using namespace std;

/**
Reverse a sentence.
*/
class Sentence
{
public:
/**
Creates a Sentence object.
@param aPhrase a sentence to reverse.
*/
Sentence(string aPhrase);

/**
Reverses this sentence.
@return the reversed sentence
*/
string reverse();

private:
string phrase;
};

Sentence::Sentence(string aPhrase)
{
phrase = aPhrase;
}


string Sentence::reverse()
{
if (phrase != "")
{
string c = phrase.substr(0, 1);
string rest = phrase.substr(1, phrase.length() - 1);
Sentence tailSentence(rest);
phrase = tailSentence.reverse() + c;
}
return phrase;
}

int main()
{
Sentence greeting("Hello!");
cout << greeting.reverse() << "\n";
return 0;
}










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
• Re: Help Running VB script in Windows 2003
• ONUNLOAD
• Re: Insert Contents of .txt file into a .html page
• Re: Perl regular expression problem.
• Re: Problems in login using WWW::Mechanize
• searching for gd::graph guide
• Re: ARRAY OF HASHMAPS
• Adv. Regexp or Otherwise
• Adv. Regexp or Otherwise


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008