Mail Archives: djgpp/1998/02/17/14:54:48
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Help with class "chicken or the egg" problem
|
Date: | Mon, 16 Feb 1998 03:58:18 -0800
|
Organization: | Alcyone Systems
|
Lines: | 35
|
Message-ID: | <34E829DA.56FBE8A8@alcyone.com>
|
References: | <6c99k6$1u6 AT bgtnsc02 DOT worldnet DOT att DOT net>
|
NNTP-Posting-Host: | 165.90.20.242
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Riley wrote:
> I am having trouble writing a program. Is there an equivalent to a
> function
> prototype but for classes??? I have two classes that have pointers to
> each
> other and I can't figure out how to define them. Attached is a simple
> demonstration program to get my point across.
Particularly in your case, the solution is very simple: Simply declare
the other class before you define the new one. If there are only
pointers involved, then you will never have a problem. This is, by the
way, exactly analogous to the situation in C where you have opaque
pointers to structures, where the compiler never learns about the
internal makeup of those structures, but doesn't have to care:
class B;
class A
{
private:
B *b;
...
};
class B ...
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm://+37.20.07/-121.53.38
\
"I've got the fever for the / flavor of a cracker"
/ Ice Cube
- Raw text -