Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

NAMESPACES AND HEADER FILES

Posted on 1999-07-29
7
Medium Priority
?
320 Views
Last Modified: 2013-11-19
Hello,

I have a problem with namespaces and header files .
I have tried to replicate JAVA language in C++ . I have created many namespaces . In a namespace i have included other namespaces which i want to use . The include namespaces may include other namespaces and they in turn may include the same namespace . I am getting a class not defined in my namespace even though I have include the namespace where it was defined .
How do I solve this problem ???
0
Comment
Question by:CHETHAN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Accepted Solution

by:
gurpreets earned 400 total points
ID: 1201404
Have you used the statement:

using namespace <NAMESPACE>;
0
 

Author Comment

by:CHETHAN
ID: 1201405
HELLO GURPREET,

That is not my problem . I have done
using namespace <NAMESPACE>

My problem is that i have included so many namespaces and suppose i have one namespace which says
namespace com_debug{
class A{
public:
static int debug();
};
}

then similarly i have another namespace say
namespace com_use{

using namespace com_debug;
int i = debug();
}

in the second namespace it is not able to able to recognise debug ???

Chethan
0
 
LVL 9

Expert Comment

by:jasonclarke
ID: 1201406
you would need to write:

namespace com_use{
    using namespace com_debug;
    int i = A::debug();
}

in your example.  Remember that classes act as a namespace for static methods.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:CHETHAN
ID: 1201407
ok jason,

I have done A::debug ....
it is still giving problems ...
I am doing a very big project and so there are a lot of namespaces involved , so it is not able to recognise the namespaces . What are the precautions to be taken while working with namespaces .

Chethan
0
 
LVL 9

Expert Comment

by:jasonclarke
ID: 1201408
Can you give more information on the types of problems?  Is the compiler complaining about not being able to find symbol names?

What compiler are you using? There are some issues with VC++ and namespaces.
0
 

Author Comment

by:CHETHAN
ID: 1201409
Hello Jason,
The compiler is  complaining about not being able to find symbol names .
I am using VC++ version 6 .

This is a huge project . So I have my code blocks in different namespaces .
when i am writing a new namespace and want to use the features of another namespace i do the using namespace . The previous namespace that I had writen was in a header file . So in my new namespace i include that header file also .
But when i compile the compiler tells me that it cannot find the symbols in the old namespace ...
Should i change my compiler settings ...

Chethan


0
 
LVL 9

Expert Comment

by:jasonclarke
ID: 1201410
I don't think there is any need to change your compiler settings.  Namespaces should work OK.

Have you a small code sample that you can't get to work?

As I said, there are some issues with namespaces and MS VC++.  Look at:

http://support.microsoft.com/support/kb/articles/Q167/3/21.ASP
http://support.microsoft.com/support/kb/articles/q167/3/50.asp


0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question