473,228 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,228 software developers and data experts.

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 1838

<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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.