473,473 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Fwd declarations crossing namespaces

I'm using 2005.Net C++ compiler. I have a base class in namespace A
(call it Class1). I derive another class from it, (call it Class2)
defined in namespace B. This derived class contains as a member datum
a pointer to an object of type Class3 from namespace A, and thus
requires forward declaration. I attempted the following in the Class 2
hpp file:

#include "Class1.hpp" // << Base class "A::Class1" - need this of
course.

namespace B{

// >Fwd declare class 3 from namespace A:

class A::Class3; // << Compiler can't seem to understand this fwd
declaration??

// >Define the derived class:

class Class2 : public A::Class1
{
// >Member data pointer to object of type A::Class3:

A::Class3* m_obj3; // << This is why I included the fwd
declaration:
};

}

What in the world is wrong with the forward declaration?

Unfortunately the only work-around that I have found is to "#include
Class3.hpp" - which I hate to do in .hpp files.

Anyone understand this?
EWL

Aug 3 '07 #1
1 1849

<ja**********@gmail.comwrote in message
news:11*********************@57g2000hsv.googlegrou ps.com...
I'm using 2005.Net C++ compiler. I have a base class in namespace A
(call it Class1). I derive another class from it, (call it Class2)
defined in namespace B. This derived class contains as a member datum
a pointer to an object of type Class3 from namespace A, and thus
requires forward declaration. I attempted the following in the Class 2
hpp file:

#include "Class1.hpp" // << Base class "A::Class1" - need this of
course.

namespace B{

// >Fwd declare class 3 from namespace A:

class A::Class3; // << Compiler can't seem to understand this fwd
declaration??

// >Define the derived class:

class Class2 : public A::Class1
{
// >Member data pointer to object of type A::Class3:

A::Class3* m_obj3; // << This is why I included the fwd
declaration:
};

}

What in the world is wrong with the forward declaration?

Unfortunately the only work-around that I have found is to "#include
Class3.hpp" - which I hate to do in .hpp files.

Anyone understand this?
EWL

namespace A {
class Class3; // forward declaration
}

namespace B {
class Class2 : public A::Class1
{

A::Class3* m_obj3;
};
}

Aug 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: matthew polder | last post by:
Hi, I have two libraries that used different namespaces, call them "fruit" and "vegetable." In one of the class definitions of fruit, I have the following. class corn; //This doesn't work. ...
2
by: Keith Davies | last post by:
Hi All, I'm sure this is possible, but I haven't seen how it's done. I'm generating XHTML from XML using Saxon (6.5.3). My output files end up with the namespace declarations from the...
4
by: whithers | last post by:
How do I do forward declarations when namespaces are involved? For example, given the following: -------------------------------------ClassA.h #ifndef CLASSA_H #define CLASSA_H namespace...
6
by: Steven T. Hatton | last post by:
Should I be able to forward declare something from a namespace different from the current one? For example the following code compiles: //testdriver.hpp #ifndef TESTDRIVER_HPP #define...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
8
by: Simon Brooke | last post by:
I was debugging a new XML generator tonight and trying to determine why it wasn't working; and realised my dom printer does not output XML namespace declarations. My method to output an Element...
14
by: António Marques | last post by:
Hi! I don't think I've ever been here, so I assume I'm addressing a bunch of nice people. Can you help me? I don't think there's a solution, but who knows. The thing is, picture a large...
10
by: Andy Fish | last post by:
hi, I have an XSLT which is producing XML output. many of the nodes in the output tree contain namespace declarations for namespaces that are used in the source document even though they are...
4
by: =?iso-8859-1?q?S=E9bastien_Ros?= | last post by:
I have to process the xmlns declarations in the root node of a document. Unfortunately, they are not recognized as elements nor as attributes. Even with a /root/node() I can't reach them. ...
3
by: Nicolas George | last post by:
Hi. I would like to simplify the namespaces declarations, something like that: <html xmlns="http://www.w3.org/1999/xhtml"> <html:em xmlns:html="http://www.w3.org/1999/xhtml">foo</html:em>...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.