Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: MoNksBaNe_Agahnim on January 02, 2004, 11:49 PM

Title: Classes
Post by: MoNksBaNe_Agahnim on January 02, 2004, 11:49 PM
Hey hey,

I may get flamed but oh well. I have been studing classes for a couple of days now and am wondering what a good project, not necessarly one as big as a bot, to practice with, my teacher doesn't know crap about C++ and all the tutorials I have used don't give you an excercise. So what is a good program to mess around with to better understand classes.

**Note** I haven't gotten much into inheratence or any of Polymorphism.

Thanks for help ^^
Title: Re:Classes
Post by: iago on January 03, 2004, 07:15 AM
Well, if you don't mind Java code, I can show you examples of inheritance/polymorphism fairly easily (try http://www.valhallalegends.com/iago/JavaBot.rar, I think that's the right link).  That one uses polymorphism to process events.  It's basically done the same way in C++ *except* you have to declare the function as virtual, so instead of this java:
public class moo
{
public boolean iagorox() { return true; }
}


you'd have this equivolant c++:

class moo
{
public:
virtual bool iagorox() { return true; }
}


but take a look at that code, see if you can tell what's happening.  You don't even have to run it, but if you want to anyway get java+netbeans from java.sun.com.
Title: Re:Classes
Post by: MoNksBaNe_Agahnim on January 03, 2004, 02:09 PM
thanks bro :)