using-declaration vs. using-directive

  • Thread starter Insert Pseudonym Here
  • Start date
I

Insert Pseudonym Here

In FAQ 15.03, it is stated, "Note that a using directive does not declare
any variables; it merely makes names available." No similar mention is
made for using-declarations. Based on the name alone, I assume using-
declarations DO declare variables. Is this assumption correct? If so,
what's the practical difference between one of them declaring a variable,
and the other not? For that matter, what the theoretical difference?
 
R

Rob Williscroft

Insert Pseudonym Here wrote in
in comp.lang.c++:
In FAQ 15.03, it is stated, "Note that a using directive does not
declare any variables; it merely makes names available." No similar
mention is made for using-declarations. Based on the name alone, I
assume using- declarations DO declare variables. Is this assumption
correct?

Yes they declare names, but names that have been declared elseware.

If so, what's the practical difference between one of them
declaring a variable, and the other not? For that matter, what the
theoretical difference?

namespace A
{
int a;
};

namespace B
{
int a;

using namespace A; /* doesn't declare anything */
using A::a; /* whoops redeclares B::a */
};


Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top