Topic: Forward declaration for a namespace


Author: Ryszard Kabatek <rysio@rumcajs.chemie.uni-halle.de>
Date: 1999/04/09
Raw View
I would like to create a namespace for a project.
It should consist of other namespaces:

// file1.h
namespace X {

typedef int Count_t;
}

// file2.h
namespace Y {

// Declarations
}


// file3.h
namespace Z {

using namespace X;
using namespace Y;

}


//file.cc
#include "file3.h"
#include "file1.h"

int main()
{
  Z::Count_t x;
  // ...
}


It does not compile (egcs-1.1.2).
My intention is not to include file1.h and file2.h into file3.h.
I need a forward declaration for a namespace.

One way is:


// file3.h

namespace X {}   // forward declaration
namespace Y {}   // forward declaration

namespace Z {

using namespace X;
using namespace Y;

}


Is it the right way?


--
Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical
Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 Fax. +49 3461 46 2129
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: ncm@nospam.cantrip.org (Nathan Myers)
Date: 1999/04/10
Raw View
Ryszard Kabatek <kabatek@chemie.uni-halle.de> wrote:
>I need a forward declaration for a namespace.
>One way is:
>
>namespace X {}   // forward declaration
>namespace Y {}   // forward declaration

>Is it the right way?

Yes.

--
Nathan Myers
ncm@nospam.cantrip.org  http://www.cantrip.org/
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]