Please, I need a hug.
And thinks it's funny. Stupid bully. Sorry to interrupt the celebrations here, but please, I need a hug.
I'm sorry, sweetie.
code:HobbesPerson Kat = new Person ("Kat");
for (int i = 0; i < Kat.NumHugsNeeded (); i++) {
Kat.GiveHobbesHug ();
}
code:Hobbes#include <string.h>
#include <fstream.h>
class Person {
public:
Person () : Name (NULL), FileName (NULL), HugsNeeded (0), Hugs (0) {}
Person (char *GivenName) : Name (new char [strlen (GivenName) + 1]),
FileName (new char [strlen (Name)+5]) ,Hugs (0) {
strcpy (Name, GivenName);
strcpy (FileName, Name);
strcat (FileName, ".hug");
ifstream in (FileName);
in >> HugsNeeded;
in.close ();
out.open (FileName);
}
~Person () {out.close ();}
void GiveHug (char *Hugger) {
out << Name << " recieved a hug from " << Hugger << ", " << Hugs << " total hugs." << endl;
Hugs++;
}
void GiveHug (Person &Hugger) {
GiveHug (Hugger.Name);
}
int GetHugsNeeded () inline {return HugsNeeded;}
private:
char *Name;
char *FileName;
ofstream out;
int HugsNeeded;
int Hugs;
};
int main (int argc, char **argv) {
Person Kat ("Kat");
for (int i = 0; i < Kat.GetHugsNeeded (); i++) {
Kat.GiveHug ("Hobbes");
}
return 0;
}
code:Hobbes32
. And I wouldn't count on it, unless you're really turning up the optimization flags. However, I definitely support writing it that way, because the number of hugs needed might change with time (which would of course be accomodated by changing the gethugsneeded method to calculate the ones currently needed at any given time).
You certainly deserve better, as demonstrated by your putting up with them so long (and let me tell you, that's far better than I would do)
(Low, low rates!)
.
.
.code:The first line assigns kathugs (not really a variable in the sense of a C program) a list which consists of the value "(((kat)))" followed by . . . . itself. This constructs an infinite list. In a non-lazy language, this would be a problem, because in the attempt to evaluate itself the structure would keep cycling forever. However, in a lazy language this is not problem -- I could then say something like takeFirst kathugs and it would return the first element of kathugs -- "(((kat)))", despite that there were infinitely more elements there it wouldn't bother Haskell one bit, because it ignored them, not needing them to find the first element.kathugs = "(((kat)))" : kathugs
main = map putStrLn kathugs
No cashing of any sympathy thread a year card here.code:I'm implementing mine in hardware.
| |
| KatSad HugKat |
+----| |---------------( )---+
| |
| HugKat DadBad KatSad |
+----|\|-----| |-------( )---+
| |
| |
Family is complicated!!! Good luck, sweetie -- and hugs whenever you need 'em!
![[Smile]](smile.gif)