Topic: Forward declaration of class in a namespace


Author: "John Keenan" <jskeenan@primustech.com>
Date: 1999/09/22
Raw View
James Kuyper Jr. wrote in message <37E818C2.70192ED0@wizard.net>...
>John Keenan wrote:
>>
>> What is the proper method to "forward declare" a class which is in a
>> namespace.
>
> namespace my_namespace
> {
> class Myclass;
> }
>
>You re-open the namespace later to complete the class declaration.

That is exactly what I was looking for... Thank you very much. I search hard
though my documentation but was not able to find this info... but now having
seen the answer, I am surprized I was not able to deduce it as it is
extremely consistent (as would be expected).



[ 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: "Paul Grealish" <paul.grealish@uk.geopak-tms.com>
Date: 1999/09/22
Raw View
John Keenan wrote in message ...
>
>What is the proper method to "forward declare" a class which is in a
>namespace.

You need to open the namespace
before declaring the fwd-ref. eg:

namespace Namespace
{
    class SomeClass; // fwd-ref
}

Namespace::SomeClass* pSomeClass;

HTH.

+-------------------------------+
|         Paul Grealish         |
|    Bentley Transportation     |
|      Cambridge, England       |
|   paul.grealish@bentley.com   |
+-------------------------------+




[ 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: "John Keenan" <jskeenan@primustech.com>
Date: 1999/09/21
Raw View
What is the proper method to "forward declare" a class which is in a
namespace.

John Keenan
www.primustech.com



[ 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: "James Kuyper Jr." <kuyper@wizard.net>
Date: 1999/09/22
Raw View
John Keenan wrote:
>
> What is the proper method to "forward declare" a class which is in a
> namespace.

 namespace my_namespace
 {
  class Myclass;
 }

You re-open the namespace later to complete the class declaration.
---
[ 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: "Darin Adler" <darin@bentspoon.com>
Date: 1999/09/22
Raw View
John Keenan <jskeenan@primustech.com> wrote:

> What is the proper method to "forward declare" a class which is in a
> namespace?

    namespace N {
        class C;
    }

    -- Darin


[ 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: whbloodworth@usa.net (William H. Bloodworth)
Date: 1999/09/22
Raw View
On 21 Sep 1999 21:56:08 GMT, "John Keenan" <jskeenan@primustech.com> wrote:

>What is the proper method to "forward declare" a class which is in a
>namespace.
>
>John Keenan

namespace JohnsNamespace
{
   class Forwarded;

   class UsesForwarded
   {
   public:
      Forwarded * pForwarded;
   };

   class Forwarded { // body };
};

Wil Bloodworth

=====================================================================
= Great Achievement REQUIRES Great Effort.
=
= William H. Bloodworth - whbloodworth@usa."net"        ICQ: 21901934
=====================================================================



[ 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              ]