Re: 7.1 vs 8.0: Inheritance and Events
- From: "Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@xxxxxxxxxxxxxxx>
- Date: Wed, 18 Apr 2007 20:51:20 -0700
rwf_20 wrote:
Consider the following (/clr:oldSyntax):
[code snipped]
In VisualStudio 2003, this code calls the base class event handler:
"myPanel::OnPanelActivated()"
This is clearly a bug.
In VisualStudio 2005, this code calls the derived class event handler:
"derivedPanel::OnPanelActivated()"
This is correct.
So, my questions are:
Which one should be called? I would think that the 2005 behavior is
correct; however, the static scoping of the function pointer
(&myPanel::OnPanelActivated) concerns me.
I agree.
Is there a way to make this work in both versions? Keep in mind that,
in my real application, the code calling add_PanelActivated knows only
the base type.
I assume that what you want is the 2005 behavior in the 2003 build, right?
In that case, I would think that you'd have to do something like provide a
pure virtual function in your base class that every derived class must
override. Form the pointers to members from within the implementations of
that virtual function, and call that new virtual function from your
add_PanelActivated function rather than composing the pointer to member
directly at that point.
-cd
.
- References:
- 7.1 vs 8.0: Inheritance and Events
- From: rwf_20
- 7.1 vs 8.0: Inheritance and Events
- Prev by Date: Re: Exporting C++ classes as ordinals (via a def file)
- Next by Date: composite & user control that contains a class
- Previous by thread: 7.1 vs 8.0: Inheritance and Events
- Next by thread: exporting a struct with an array from a C++ dll to be accessed in C#
- Index(es):
Relevant Pages
|