-=> ``Tical`` wrote to Paul Druggitt <=-
``> This is a C++ question
Not really... this works in C, too. :-)
``> I was reading in a C++ book that inside of structures, you can
``> define data types of that structure... Like so:
``>
``> struct list
``> { char monkey;
``> list *list;
^
|- notice this!
``> list *invertebrate;
``> int beligerant;
``> }
What you've done is not to declare a structure within itself, but rather a
*pointer* to a structure of that type. Storage must be allocated to those
pointers manually, via "malloc" (for C) or "new" (for C++). That's how
lists are built.
``> it seems that some sort of infinite loop would be created because the
``> structure would be creating variables of that structure which, in
``> turn, would create more variables of that structure, etc., etc.
Since they're only pointers, not structures, there's no automatic
recursion in their creation.
... Data, data everywhere, and not a byte to eat!
---
1:109/570)
---------------
* Origin: * My Place BBS * Bowie, Md USA * V.34 * (301)805-1602 *
|