May 05, 2024, 06:13:11 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Difference between a derived class and a sub class

Started by Kale, July 19, 2006, 02:30:44 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Kale

Can anyone please explain what is the difference between a derived class and a sub class. I always thought they were the same thing.

Zen

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

Kale

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.

Ionic Wind Support Team

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.

Ionic Wind Support Team

Kale

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?

Ionic Wind Support Team

Yes. 

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

Which is what virtual functions are for.
Ionic Wind Support Team