Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > using-declaration vs. using-directive

Reply
Thread Tools

using-declaration vs. using-directive

 
 
Insert Pseudonym Here
Guest
Posts: n/a
 
      05-03-2004
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?
 
Reply With Quote
 
 
 
 
Rob Williscroft
Guest
Posts: n/a
 
      05-03-2004
Insert Pseudonym Here wrote in
news:Xns94DDEDA7A9178iphiphfakeaddrcom@68.12.19.6 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.
--
http://www.victim-prime.dsl.pipex.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments