forward declarations with subclasses

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using .NET version 2.0 and implementing all my event handlers to use the
new generic type. The problem I am running into is most of my Event Arguments
are defined in a single header which requires me to place some forward
declarations in sorce files that reference these classes. The new generic
EventHandler<T> requires that T is of a type EventArgs. My question is how do
I create a forward declaration that includes the base class?

ref class MessageArgs : public EventArgs
{
public:
MessageArgs(String^ theMessage);
}

event EventHandler<MessageArgs^>^ NewMessage;
 
NickC said:
I am using .NET version 2.0 and implementing all my event handlers to
use the new generic type. The problem I am running into is most of my
Event Arguments are defined in a single header which requires me to
place some forward declarations in sorce files that reference these
classes. The new generic EventHandler<T> requires that T is of a type
EventArgs. My question is how do I create a forward declaration that
includes the base class?

AFIAK, you can't (you definitely can't in ISO Standard C++). You'll have to
arrange for the full definition of the eventargs class to be seen in order
for the generic to compile.

-cd
 
Thanks for the answer Carl. That is what I thought but I just wanted to see
if there was a new C++ extensions that allows for this. I reorgainized my
header files to fix the compiler errors I was getting so I am at least up and
running. It would be nice to declare a class as having a specific base class.
Have you heard if this extension is going to be added?
 
NickC said:
Thanks for the answer Carl. That is what I thought but I just wanted
to see if there was a new C++ extensions that allows for this. I
reorgainized my header files to fix the compiler errors I was getting
so I am at least up and running. It would be nice to declare a class
as having a specific base class. Have you heard if this extension is
going to be added?

I've seen the idea come up before, but I'm not aware of any extension effort
to support it (that doesn't mean that there isn't one though).

-cd
 
Back
Top