473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

forward declarations with subclasses

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;

Jun 9 '06 #1
3 1333
NickC wrote:
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
Jun 10 '06 #2
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?

"Carl Daniel [VC++ MVP]" wrote:
NickC wrote:
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

Jun 12 '06 #3
NickC wrote:
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
Jun 12 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mjm | last post by:
Folks, Please help me with the following problems: ******************************************** 1. I have a class template template<class Base> class Matrix : public Base { /* .... */ }
6
by: Steven T. Hatton | last post by:
Should I be able to forward declare something from a namespace different from the current one? For example the following code compiles: //testdriver.hpp #ifndef TESTDRIVER_HPP #define...
5
by: John Gabriele | last post by:
I'm hoping someone can please help me remember the C++ rule: When you're writing a header file for a class (say, some_namespace::Bar), and that class makes use of another class...
11
by: aleko | last post by:
This applies equally to function prototypes. Why do we have to tell the compiler twice? Other modern compiled languages don't have this requirement. Just curious, Aleko
9
by: vishnu | last post by:
what is the exact difference between including a class header file and forward declaration. and Is there a case , where in forward declaration is not possible and including is .
2
by: Neo | last post by:
Hi, I am new to C++ and want to know what are forward declarations and any site which has a good introductory explanation. thanks in advance, nick
12
by: fox | last post by:
How do I (portably) make a forward reference to a static (I mean file-scope) variable? I've been using "extern" for years, for example: extern int x; int foo(void) { return x++; }
2
by: Carlos Martinez Garcia | last post by:
Hi all: I usually make forward declarations in headers. Something like this: class MyClass; Now, I need a reference to a type defined like this (traditional C Style): typedef struct {
0
by: Rune Allnor | last post by:
Hi all. I have these classes, implemented as templates in header files. Right now I have one file per class, where both the declarations and implementations of one class are located in each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.