Solved

Header Question (namespaces)

Posted on 2003-10-27
1
230 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

808 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