delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/06/04:19:29

Message-ID: <c=GB%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-970306090424Z-114@crianlarich.Indigo>
From: Robert Humphris <r DOT humphris AT indigo-avs DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>,
"'an118 AT chebucto DOT ns DOT ca'"
<an118 AT chebucto DOT ns DOT ca>
Subject: RE: HELP - need help resolving conundrum with classes
Date: Thu, 6 Mar 1997 09:04:24 -0000
Encoding: 23 TEXT

>How can I declare two different classes, where each class has a member 
>variable of the other class type. My problem is how to get the compiler to 
>recognize a variable type before it has been created.

Simple there are 2 ways of doing this, 1 declare both as being from a
related class
class catObj ....

the_cat : public catObj
// refer to owner as 
catObj *owners;
... .
class the_owner : public carObj...


Or the simplest method is before you define either class, prototype
them!:
class the_cat;
class the_owner;

Have fun...

Rob Humphris

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019