Mail Archives: djgpp/1997/03/07/17:52:33
On Thu, 6 Mar 1997 15:33:20 -0000, you wrote:
>Sorry, but you are wrong, the code example shows you declaring an
>instance of the owner class, a prototype
>is done before the class is defined or instanciated, you will more often
>than not have such prototypes in=20
>header files so that other classes can use their type, and compile
>modularly.
>
>Rob Humphris
>
The example can't work 'cos the compiler doesn't have a chance of
determining the actual class size (I mean the first declared one,
the_cat) , the forward declaration doesn't carry enough information
for this.=20
The only way to get the program work is to forward declare the_owner
and then use a pointer (or a reference) to the_cat, this way:
class the_owner;
class the_cat
{
the_owner *its_owners;
// other stuff
....
};
class the_owner
{
the_cat cats_owned[5];
// other stuff
....
};
Marco
- Raw text -