473,499 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

namespace is not visible in a class?

I include 2 headers: the first defines some namespace A and the second
defines class B which contains some member instances of classes defined in
namespace A.

header1:

namespace A
{
class C;
};

header2:

class B
{
A::C c_instance;
};

Why does the compiler complain during compilation of header2 that A is not a
namespace?

Mar 28 '07 #1
6 2358
On Mar 29, 12:01 am, "r.z." <g...@hjkjhk.plwrote:
I include 2 headers: the first defines some namespace A and the second
defines class B which contains some member instances of classes defined in
namespace A.

header1:

namespace A
{
class C;

};

header2:

class B
{
A::C c_instance;

};

Why does the compiler complain during compilation of header2 that A is not a
namespace?
My compiler says "field 'c_instance' has incomplete type" when tried.

Could you post some minimal code that shows the error?
Mar 28 '07 #2
My compiler says "field 'c_instance' has incomplete type" when tried.

Could you post some minimal code that shows the error?
just put class C definition instead of its declaration in namespace A and it
shoul give you the same error as me

Mar 28 '07 #3
r.z. wrote:
I include 2 headers: the first defines some namespace A and the second
defines class B which contains some member instances of classes defined in
namespace A.

header1:

namespace A
{
class C;
};

header2:

class B
{
A::C c_instance;
};

Why does the compiler complain during compilation of header2 that A is not a
namespace?
Because you haven't included header1?

--
Ian Collins.
Mar 28 '07 #4
Because you haven't included header1?

it is included - I can use A::C c_instance in main.cpp but not in header2.

Mar 28 '07 #5
On Mar 29, 12:25 am, "r.z." <g...@hjkjhk.plwrote:
My compiler says "field 'c_instance' has incomplete type" when tried.
Could you post some minimal code that shows the error?

just put class C definition instead of its declaration in namespace A and it
shoul give you the same error as me
Nope, the next compiles fine;
namespace A
{
class C{
public:
C(){};
};
};

class B
{
A::C c;
};

int main(void)
{
B b;
return 0;
}
So, or your compiler is wrong, or there is something else that is
important to the problem in your code that you havn't posted to this
group yet....

Mar 28 '07 #6
SOLVED.
I did forget to include header1 in header2.
I am an ass of a developer.
thanks for comments.

Mar 28 '07 #7

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

Similar topics

4
4556
by: prasat | last post by:
What does namespace signify in C++ -- Posted via http://dbforums.com
2
7472
by: Birt | last post by:
An article states: the global namespace be polluted, causing "a namespace collision." What does this mean exactly? Thank you very much!
3
1655
by: janek | last post by:
I have a question: what differences are between: namespace Mary { int r = 5 ; char m ;
6
24729
by: Robert Warnestam | last post by:
I've two class libraries, where one is referencing the other. The first library looks like this; (assembly name and root name space is set to Codab.Parser) namespace Codab.Parser { public class...
9
5393
by: Ivan Mascovich | last post by:
Previous posts (and compilers) confirm that class X { friend void Y() ; } ; does not match namespace
3
2584
by: Tomás | last post by:
I have a header file/source file combo. There's approximately five functions in the source file. Only one of the functions should be used by other translation units, so I've defined the other...
3
1805
by: toton | last post by:
Hi, Is it possible to have a class level namespace opening instead of file level . Something like this, I have a long namespace like namespace com { namespace my_company{ namespace...
7
2060
by: Juha Nieminen | last post by:
This is possible: namespace X { class A; } class X::A { <implementation}; However, what about nameless namespaces? Does this do what I want? namespace { class A; }
3
9527
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
22
3879
by: Luna Moon | last post by:
I am reading the book "C++ Annotations", and here is a quote from the book: Namespaces can be defined without a name. Such a namespace is anonymous and it restricts the visibility of the...
0
7007
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
7174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7388
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
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3099
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
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
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.