Solved

Header Question (namespaces)

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

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!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

691 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