delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/04/04:30:14

Message-ID: <c=GB%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-970604083322Z-121@crianlarich.Indigo>
From: Robert Humphris <r DOT humphris AT indigo-avs DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>, "'darn AT xl DOT ca'" <darn AT xl DOT ca>
Subject: RE: compiling interdependent C++ classes
Date: Wed, 4 Jun 1997 09:33:22 +0100
Encoding: 57 TEXT


>----------
>From: 	Darren Grant[SMTP:darn AT xl DOT ca]
>Sent: 	02 June 1997 02:08
>To: 	djgpp AT delorie DOT com
>Subject: 	compiling interdependent C++ classes
>
>Hello,
>
>I am having extreme difficulty compiling a collection of interdependent
>C++ classes (using RHIDE).  i.e. Given classes A and B, the situation is
>like to A requiring B and vice versa.  
>
>Each class has its own .cpp (class implementation only) and associated
>header file (#include directives and class declaration only).  While
>BC++ has absolutely no problems with this arrangement, DJGPP returns all
>sorts of errors consistent with the attempted use of undeclared classes.
>(Not only that, but DJGPP isn't trapping circular #includes, which is
>highly annoying!)
>
>Thanks.

Can you not just declare the class prototypes in a headerfile:

sharedHeader.h

#ifndef _SHARED_HEADER_H_
#define _SHARED_HEADER_H_

class A;
class B;


class A 
{
private:
  int a, b, c;
  B* ptrToBType;
public:
  A();
  ~A();
};


class B
{
private: 
  int a, b, c;
  A *ptrToAType;
public:
  B();
  ~B();
};

#endif
>

- Raw text -


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