delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/11/20:45:30

Message-ID: <38F3CAFB.5497C6BC@home.com>
From: Robin Johnson <robbat2 AT home DOT com>
Organization: Orbit Computers
X-Mailer: Mozilla 4.7 [en] (Win98; U)
X-Accept-Language: en,af,es
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: classes?
References: <38F3FDB4 DOT DCDEBD61 AT rug DOT ac DOT be>
Lines: 49
Date: Wed, 12 Apr 2000 01:01:33 GMT
NNTP-Posting-Host: 24.113.36.103
X-Complaints-To: abuse AT home DOT net
X-Trace: news1.rdc1.bc.home.com 955501293 24.113.36.103 (Tue, 11 Apr 2000 18:01:33 PDT)
NNTP-Posting-Date: Tue, 11 Apr 2000 18:01:33 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Use forward declarations.

Bram de Greve wrote:
> 
> If have this strange problem, can anyone help me please ???
> 
> Say, I have two classes Class1 and Class2.
> I have the the stuff (interface and implementation) of Class1 in
> class1.hpp and class1.cpp.
> The stuff of Class2 is in class2.hpp and class2.cpp.
> Both classX.hpp are done with
>    #ifndef __CLASSX_HPP_
>    #define __CLASSX_HPP_
>    ...
>    #endif
> so I can't include twice the same file.
> So far, so good,  I can compile both class1.cpp and class2.cpp.
> 
> Now, in Class1, I need a member object of Class2
>    class Class1
>    {
>       Class2 * myClass2;
>       ...
>    };
> Thus in class1.hpp, I include "class2.hpp" so that Class1 "knows"
> Class2.
> 
> I also need a member object of Class1 in Class2
>    class Class2
>    {
>        Class1 * myClass1;
>        ...
>    };
> Thus in class2.hpp, I include "class1.hpp".
> 
> MY PROBLEM IS: THIS NEW SITUATION WILL NOT COMPILE!!!
> WHY???
> 
> Thanks in advance,
> Bramz

-- 
Robin Hugh Johnson
"Robbat2"
QTOD: "I used to be an idealist, but I got mugged by reality."
E-Mail     : robbat2 AT tesla DOT t-p-l DOT com
ICQ#       : 30269588 or 41961639
Home Page  : http://robbat2.t-p-l.com
Time Zone  : Pacific Daylight (GMT - 8)

- Raw text -


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