www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/07/02:18:43

From: "Sly" <sly AT antispam DOT aussie DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP - need help resolving conundrum with classes
Date: 7 Mar 1997 05:51:38 GMT
Organization: Sly
Lines: 36
Message-ID: <01bc2abc$2990b960$82081ecb@sly>
References: <5fl6a5$4ic AT News DOT Dal DOT Ca>
Reply-To: "Sly" <sly AT aussie DOT net>
NNTP-Posting-Host: max0ppp00.bne.aussie.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Graham Howard Wile <an118 AT chebucto DOT ns DOT ca> wrote in article
<5fl6a5$4ic AT News DOT Dal DOT Ca>...
> 
> 	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.
> 

Try jusr declaring the other class first, but defining it later.  Like..

class the_owner;

class the_cat
{
	private:
		int its_age, its_weight;
		char *fur_color;
		the_owner its_owners[3];
	...
}

class the_owner
{
	private:
		the_cat cats_owned[5];
		...
}

Hope this helps.

-- 
TTFN
Sly (Steve)
sly AT aussie DOT net

- Raw text -


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