Subclassing
-
-
toxcct wrote:
class ChildClass : BaseClass {
class ChildClass : **public** BaseClass {
class ChildClass : **protected** BaseClass {
class ChildClass : **private** BaseClass {
Maxwell Chen
-
what is subclassing actually?? how do u create a subclass in SDK and MFC? Thanks in advance Regards, Prashanth.v
-
i'm working for zilog,bangalore. n u?
-
i'm working for zilog,bangalore. n u?
-
What a discussion thread and out of context topics !!! .
-
What a discussion thread and out of context topics !!! .
-
sorry all.
-
subclassing
is not a MFC nor SDK concept but a C++ (and even general OO) concept. it means using a base class to reuse its behavior/design/methods and not reinventing the wheel... another good term for this is alsoinheritence
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
Is always tought that subclassing was to change the behaviour of a class in a framework without changing the framework. I guess i'm wrong but what is then the correct term for this kind of pattern. Let me explain by a simple example. You create your own windowproc which is then used to overwrite the normal winproc. By using your own windowproc you can change the behaviour of the subclassed window. codito ergo sum
-
Is always tought that subclassing was to change the behaviour of a class in a framework without changing the framework. I guess i'm wrong but what is then the correct term for this kind of pattern. Let me explain by a simple example. You create your own windowproc which is then used to overwrite the normal winproc. By using your own windowproc you can change the behaviour of the subclassed window. codito ergo sum
in what way would that be different from what i explained ? you can always inherit from a base class and override some functions do change the behavior, or had some new features... ;)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
in what way would that be different from what i explained ? you can always inherit from a base class and override some functions do change the behavior, or had some new features... ;)
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
Suppose one has a working application with the following structure COrgMainFrame and COrgView loaded via a dll or unrelated part of the application. At some point in time you need to change the behaviour of one of the classes, but you are prohibitted to do this at design time time. So you can't/may not create/use CMyNewView or CMyDifferentMainFrame. The only way is to implement this is at runtime. This means override the normal behaviour of the class at runtime, by loading a new windowproc function into the message handeling part of that window you want to change. Once this is done all windows messages passes your function first instead of the PreTranslateMessage function that normaly parses the messages. So one can delete certain messages being send to the normal PreTranslateMessage function or add new functions; and altering as such the behaviour of the Original class. This doesn't have anything to do with inheritance or objects this is 'normal' windows behaviour. Each windowclass needs to be registerd in windows, this is normaly done by the MFC classes at creation of the window, this is needed to let windows now what windowproc needs to be called for this kind of window. Using the technique explained above one can alter the behaviour of one single instance of that class/window without changing the behaviour of other instances of the same object. I hope I have explained it clearly ennough what I meant. :) Like i said before I always thought that this was called subclassing in windows codito ergo sum