Flare Sci-fi Forums
Flare Sci-Fi Forums Post New Topic  New Poll  Post A Reply
my profile | directory login | search | faq | forum home

  next oldest topic   next newest topic
» Flare Sci-Fi Forums » Community » Officers' Lounge » C++ question

   
Author Topic: C++ question
Daniel Butler
I'm a Singapore where is my boat
Member # 1689

 - posted      Profile for Daniel Butler     Send New Private Message       Edit/Delete Post   Reply With Quote 
I've got an assignment for my C++ class that I'm a bit confused about... There's a class MyString that has a public method length() which returns an int and takes no arguments. We're supposed to implement it using indirect recursion with a private function called recursiveLength that does take a value... thing is, I don't really understand how to use a function that has no parameters recursively. Can anybody help me out?
Registered: Jul 2005  |  IP: Logged
Charles Capps
We appreciate your concern.
It is noted and stupid.
Member # 9

 - posted      Profile for Charles Capps     Send New Private Message       Edit/Delete Post   Reply With Quote 
You'll have to store the state of the function as a property of the object, then just have the function refer to that. At least that's how it'd be done in any other OO language.

That being said, WTF would you ever need a recursive function for to measure a string? Shouldn't there be some sort of standard library call?

Registered: Mar 1999  |  IP: Logged
Daniel Butler
I'm a Singapore where is my boat
Member # 1689

 - posted      Profile for Daniel Butler     Send New Private Message       Edit/Delete Post   Reply With Quote 
We're not allowed to use strlen() because we're supposed to be writing the standard library functions right now to learn how they work. Still, I wouldn't do it recursively if he didn't make us...
Registered: Jul 2005  |  IP: Logged
Cartman
just made by the Presbyterian Church
Member # 256

 - posted      Profile for Cartman     Send New Private Message       Edit/Delete Post   Reply With Quote 
Half-assed assignments about recursion that demonstrate the concept in the most artificial (ie. retarded) way imaginable have mutilated more CS students than BASIC ever did. Fact.
Registered: Nov 1999  |  IP: Logged
Daniel Butler
I'm a Singapore where is my boat
Member # 1689

 - posted      Profile for Daniel Butler     Send New Private Message       Edit/Delete Post   Reply With Quote 
After this, I believe it.
Registered: Jul 2005  |  IP: Logged
   

Quick Reply
Message:

HTML is enabled.
UBB Code™ is enabled.

Instant Graemlins
   


Post New Topic  New Poll  Post A Reply Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


© 1999-2024 Charles Capps

Powered by UBB.classic™ 6.7.3