IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Kale on July 19, 2006, 02:30:44 AM

Title: Difference between a derived class and a sub class
Post by: Kale on July 19, 2006, 02:30:44 AM
Can anyone please explain what is the difference between a derived class and a sub class. I always thought they were the same thing.
Title: Re: Difference between a derived class and a sub class
Post by: Zen on July 19, 2006, 05:59:39 AM
Dont quote me, i am no programming pro but...

A derived class is like a child class that inherits all its parents methods and memebers. For instance, when creating your own window class, you ould make a derived class called MyWindow for example that is derived from the CWindow base class.

Subclassing is a method of intercepting windows messages. For example you want to subclass and edit control so that you can restrict its input to numbers only. It is basicly done by overiiding the default message handler for that control, processing the message you want and then returning the message handler back to its original one.

I may not have explained this in the best way, more from a how i see it point of view.

Lewis
Title: Re: Difference between a derived class and a sub class
Post by: Kale on July 19, 2006, 08:19:41 AM
Ah.. i see. A derived class is what i thought a sub class was. Because when using OOP, i used to refer to inheritance by sub classes (child) and super classes (parent), maybe because that is how it was originally explained to me in some book i read. I get it about sub-classing the control classes, too.
Title: Re: Difference between a derived class and a sub class
Post by: Ionic Wind Support Team on July 19, 2006, 08:46:02 AM
Deriving a class in not a parent/child relationship.  Which is why we say "base" and "derived".

A derived class is a "kind of" a base class.  A derived class has all of the functionality of the base class plus it's own methods and variables.

Title: Re: Difference between a derived class and a sub class
Post by: Kale on July 19, 2006, 09:49:09 AM
So if i code a class called 'One' and created a derived class from it called 'Two'.

Then, say i redefined a method within class 'One',  would this also change the functionality of the same method in class 'Two' providing i havn't redefined that particular method there?
Title: Re: Difference between a derived class and a sub class
Post by: Ionic Wind Support Team on July 19, 2006, 09:57:59 AM
Yes. 

Quote
providing i havn't redefined that particular method there?

Which is what virtual functions are for.
Title: Re: Difference between a derived class and a sub class
Post by: Kale on July 19, 2006, 04:05:33 PM
Great, cheers Paul. :)