Solved

Header Question (namespaces)

Posted on 2003-10-27
1
228 Views
Last Modified: 2010-04-02
Two part quesiton.

1.  Are namespaces only good for files?  If I declare using namespace x in a .h file, then I must also make that declaration in the .cpp file that includes that.  Is this correct?

2.  I am trying to do some xml stuff, and I declare using namespace MSXML2, but when I try to create a IXMLDOMDoucmentPtr I get an error because it is ambiguous.  why?
0
Comment
Question by:jjacksn
1 Comment
 
LVL 17

Accepted Solution

by:
rstaveley earned 200 total points
ID: 9631053
Ref 1: If you put using namespace into the .h, it is equivalent to putting it ito the .cpp, but it is bad practice because you are forcing anything that uses the .h to use the namespace.

Ref 2: See http://support.microsoft.com/default.aspx?scid=kb;en-us;316317
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now