Re-forward declaration of types which were already forward declared

From: qazmlp (qazmlp1209_at_rediffmail.com)
Date: 02/15/04


Date: 15 Feb 2004 10:44:55 -0800

Is it a good style to re-forward declare the types, which were already
forward declared in base header file, in derived class header file?

// base.h
class addrClass;
class base
{
  public:
  virtual void setAddress(addrClass* node);
  
  // Other members
} ;

// derived.h

// Is it a good style to forward declare addrClass here?
// As setAddress method and hence the parameter of type 'addrClass*'
// is from the base class, it may not be required, I suppose.
class derived : public base
{
  public:
  virtual void setAddress(addrClass* node);
  
  // Other members
} ;

And, similarly, what about #include-ing the header which has to be
added
only because of the Base class method signatures?



Relevant Pages

  • Re: Exported function mangaled name
    ... that header file; it must be declared as __declspec ... You have to declare the function the same way in your .cpp file as in ... #define LIBSPEC __declspec ... See my essay on The Ultimate DLL Header File on my MVP Tips site. ...
    (microsoft.public.vc.mfc)
  • Re: make general windows module
    ... The VB version of these declarations is the "Declare Statement". ... mimicing the behavior of a "windows.h" header file for VB. ... not all Windows API calls can be called from VB as some use reference ...
    (microsoft.public.vb.general.discussion)
  • Re: confused about extern use
    ... going to achieve by declaring it as extern in the header file a.h. ... composed on one or more compilation units. ... Essentially you *declare* the type wherever it is ...
    (comp.lang.c)
  • Re: Trouble with FILE
    ... reasons I had to split up this program in several modules. ... I can declare, ... extern FILE *fp1; ... included in the header file, so that the FILE type is defined. ...
    (comp.lang.c)