"Lynn" <NO****@NOSPAM.com> wrote in message
news:co********@library2.airnews.net...
class (yet). How do I generate a forward reference of a data structure ?
For
BTW, I am trying to generate forward references to this typedef'd data
structure in:
std::vector <STREAM *> hClipStrmList; /* List of streams on the clipbrd */
This forward refererence works OK, it is the formal declaration of the
STREAM_E
data structure which is blowing up.
Thanks,
Lynn
Don't use that old C-style typedef stuff. Just declare the struct like
this:
struct STREAM
{ /* Used from v5.0 */
DWORD ID; /* unique ID of stream, remains unchanged in drawing */
DWORD VertxCount; /* Number of vertices on stream */
DWORD VertxIndex; /* Index of first vertex of stream */
DWORD Layer; /* Layer that stream is drawn on */
DWORD Style; /* Line-style - dotted, dashed etc */
BYTE Hatch; /* Line-hatching - cross, sine etc */
BYTE Status; /* Status of stream */
DWORD Type; /* Line-type, ALWAYS 0 at present */
};
By the way, there is no difference between a struct and a class, except the
fact that the default visibility of the members of a class is private, while
for a struct it is public. (I think the same applies for the default type
of inheritence, but I forget now.) So if you can forward-declare a class,
you can forward-declare a struct, too. I seem to recall that there was a
version of C++ long ago where a struct was used when we just wanted to have
data in the object, and a class was used when we wanted to introduce
functions to it. That's simply not the way class and struct are defined, at
least not now. It's still common practice though, to use struct for simple
data-holding objects (which have no member functions), but that's really
just because the default visibility is public. One could just as easily use
a class, and put the public: specifier before the member variables. One
other thing: just because you don't declare any member functions, doesn't
mean they don't exist. The compiler will generate certain required
functions for you, such as a constructor, destructor, copy constructor and
assignment operator, when it needs them. It's just that there's no
"user-defined" version of them. My point is: stop thinking of struct as
simply data.. it's just like a class object, except for the
public/privatedifference(s).
-Howard