using-declaration vs. using-directive

Discussion in 'C++' started by Insert Pseudonym Here, May 3, 2004.

  1. 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?
     
    Insert Pseudonym Here, May 3, 2004
    #1
    1. Advertising

  2. 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/
     
    Rob Williscroft, May 3, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    970
  2. Alex Vinokur
    Replies:
    4
    Views:
    604
    Jonathan Turkanis
    Apr 5, 2004
  3. Ian Collins
    Replies:
    2
    Views:
    357
    Öö Tiib
    Apr 19, 2010
  4. Niels Dekker - no reply address

    Using-declaration or using-directive inside unnamed-namespace?

    Niels Dekker - no reply address, Apr 27, 2010, in forum: C++
    Replies:
    1
    Views:
    607
    Niels Dekker - no reply address
    Apr 27, 2010
  5. Vivek Sharma

    Directive Declaration

    Vivek Sharma, May 27, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
    Vivek Sharma
    May 27, 2005
Loading...

Share This Page