Click here to Skip to main content
15,889,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Virtual methods Pin
Waldermort26-Sep-07 3:47
Waldermort26-Sep-07 3:47 
GeneralRe: Virtual methods Pin
Roger Stoltz26-Sep-07 5:06
Roger Stoltz26-Sep-07 5:06 
GeneralRe: Virtual methods Pin
Waldermort26-Sep-07 5:19
Waldermort26-Sep-07 5:19 
GeneralRe: Virtual methods Pin
Roger Stoltz26-Sep-07 5:29
Roger Stoltz26-Sep-07 5:29 
GeneralRe: Virtual methods Pin
Waldermort26-Sep-07 5:37
Waldermort26-Sep-07 5:37 
GeneralRe: Virtual methods Pin
Waldermort26-Sep-07 6:28
Waldermort26-Sep-07 6:28 
GeneralRe: Virtual methods Pin
Roger Stoltz26-Sep-07 8:58
Roger Stoltz26-Sep-07 8:58 
GeneralRe: Virtual methods Pin
Waldermort27-Sep-07 5:49
Waldermort27-Sep-07 5:49 
Roger Stoltz wrote:
in this case you would create reusable base classes that you can benefit from later


I have to agree there, it's always useful to create re-usable code and add it to a common folder somewhere. I have got to the point now that I am re-using so much code, that I had to create a single header file just to #include my most used snippets.

As for this Subject Observer pattern. Most of the examples/articles I found simply pass a this pointer back to the observer through a single virtual method. In my eyes this is somewhat over the top, each observer wouldn't know what type of update or even if the update is relevent, but still have to call back to the subject to check what changed.

I took a different approach, much the same as you would normaly use virtual methods. I created a single base class, complete with a list of all virtual calls a class would need. This way the method can be over-ridden directly and whatever updated data is already there.

Infact I may even write an article on it. To think of all those projects where I could have used this, but instead took the far more complicated route of multiple derived types and callbacks...

Again, thanks for introducing this.

Waldermort

QuestionDrawing a rectangle Pin
Maynka25-Sep-07 23:12
Maynka25-Sep-07 23:12 
AnswerRe: Drawing a rectangle Pin
Hamid_RT25-Sep-07 23:29
Hamid_RT25-Sep-07 23:29 
AnswerRe: Drawing a rectangle Pin
Russell'25-Sep-07 23:55
Russell'25-Sep-07 23:55 
Questionsize of char * Pin
baerten25-Sep-07 22:42
baerten25-Sep-07 22:42 
AnswerRe: size of char * Pin
Naveen25-Sep-07 22:52
Naveen25-Sep-07 22:52 
AnswerRe: size of char * Pin
Cedric Moonen25-Sep-07 22:59
Cedric Moonen25-Sep-07 22:59 
AnswerRe: size of char * Pin
Waldermort25-Sep-07 23:08
Waldermort25-Sep-07 23:08 
QuestionRe: size of char * Pin
David Crow26-Sep-07 2:51
David Crow26-Sep-07 2:51 
AnswerRe: size of char * Pin
Nemanja Trifunovic26-Sep-07 3:37
Nemanja Trifunovic26-Sep-07 3:37 
AnswerRe: size of char * Pin
Signal-926-Sep-07 14:53
Signal-926-Sep-07 14:53 
Questionabout display of line symbol Pin
yidingyu25-Sep-07 22:26
yidingyu25-Sep-07 22:26 
AnswerRe: about display of line symbol Pin
Russell'25-Sep-07 23:58
Russell'25-Sep-07 23:58 
GeneralRe: about display of line symbol Pin
yidingyu26-Sep-07 1:04
yidingyu26-Sep-07 1:04 
GeneralRe: about display of line symbol Pin
Russell'26-Sep-07 1:18
Russell'26-Sep-07 1:18 
QuestionRe: about display of line symbol Pin
David Crow26-Sep-07 2:53
David Crow26-Sep-07 2:53 
Question"Opens with" and DDE Pin
__DanC__25-Sep-07 22:15
__DanC__25-Sep-07 22:15 
AnswerRe: "Opens with" and DDE Pin
David Crow26-Sep-07 2:54
David Crow26-Sep-07 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.