Thread: Namespace confusion.

  1. #1
    Registered User
    Join Date
    Dec 2004

    Namespace confusion.

    Hello all...
    In the god old times when a few compilers supported namespaces you could put incomplete declarations in headers file, e.g.:

    class ostream;
    class someclass {
    ostream* ptr

    Now the problem is that when I try to write:

    class std::ostream;
    class someclass {
    std::ostream* ptr;

    the compiler (g++ 3.4) gives me a warning that it expects a type-name in the line with "class std::ostream;". What to do?

  2. #2
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    You can't declare a class like that; if you want to declare the class 'ostream' within the namespace called 'std', then you do:
    namespace std
       class ostream;
    The easiest solution is, of course, just to include the <iostream> header
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. namespace problem
    By DL1 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2008, 12:10 PM
  2. global namespace errors
    By stubaan in forum C++ Programming
    Replies: 9
    Last Post: 04-02-2008, 03:11 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. data validation & namespace
    By tiange in forum C++ Programming
    Replies: 4
    Last Post: 07-05-2005, 02:45 AM