Can anyone please explain what is the difference between a derived class and a sub class. I always thought they were the same thing.
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
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.
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.
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?
Yes.
Quote
providing i havn't redefined that particular method there?
Which is what virtual functions are for.
Great, cheers Paul. :)