using s specific namespace in all class members, using directive in class header

This is a discussion on using s specific namespace in all class members, using directive in class header within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I have some memory that it was possible to write something like this: Code: class MySpecialClass { public: ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    40

    using s specific namespace in all class members, using directive in class header

    Hi everyone, I have some memory that it was possible to write something like this:
    Code:
    class MySpecialClass
    {
    public:
        using namespace boost;
    };
    And then was boost namespace visible in all member functions of that class, but of course have I forget exactly how to write it. What is the right syntax to accomplish this? I have been started to get tired of written using directive in every member function

    Thanks in advance.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,271
    Perhaps you are thinking of using that using directive at global scope, after all the includes, in the source file containing the definitions of the various member functions of MySpecialClass.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    40
    Yes, that will work, but it feels wrong and with that memory in my head is it very annoying. I haven't sleep this night either so it can be it too, but if you don't know so are it probably impossible.

    Thanks anyway.

  4. #4
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Unfortunately it seems to me that you can't use using declarations at class scope.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,271
    Quote Originally Posted by anon
    Unfortunately it seems to me that you can't use using declarations at class scope.
    You can, and that would be appropriate to bring in names from a base class that would be hidden otherwise.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Perhaps I meant using directives then - can't remember which is which. It seems to me that you can't put "using namespace boost;" where the OP wants to put it.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,646
    It is not possible to use "using namespace" directives in a class definition.

    However, there are other forms of "using" directives that are used (no pun intended) within classes.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 08-04-2009, 12:40 PM
  2. Problem with friend class declaration in a namespace
    By Angus in forum C++ Programming
    Replies: 2
    Last Post: 12-09-2008, 01:29 PM
  3. Using Vector for Members of a Class
    By bengreenwood in forum C++ Programming
    Replies: 11
    Last Post: 12-04-2007, 03:31 PM
  4. Class methods in header or source file?
    By TriKri in forum C++ Programming
    Replies: 13
    Last Post: 09-17-2007, 06:23 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21