istream and ostream not declared?

This is a discussion on istream and ostream not declared? within the C++ Programming forums, part of the General Programming Boards category; My program keeps saying istream and ostream are not declared when I'm trying to create this class: Code: #include <iostream> ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    29

    istream and ostream not declared?

    My program keeps saying istream and ostream are not declared when I'm trying to create this class:

    Code:
    #include <iostream>
    
    
    #ifndef TRANSPORT_H_
    #define TRANSPORT_H_
    
    class Transport{
          public:
                 Transport();
                 Transport(double cost);
                 double get_cost() const;
                 void set_cost(double c);
                 
                 virtual void output(ostream & outs) = 0;
                 virtual void input(istream & ins) = 0;
          
          private:
                 double cost;           
                  
    };
    
    #endif
    as you can see im including iostream, i also tried ios, istream & ostream and none work... any ideas?
    thanks

  2. #2
    Registered User
    Join Date
    Apr 2005
    Posts
    29
    ummm nevermind im an idiot, its late and i forgot my namespace

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Or better, explicitly qualify them, since this appears to be a header. And if it is a header, put the entire contents of the file between the guards.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,443
    > ummm nevermind im an idiot, its late and i forgot my namespace
    Putting namespace into header files is a good way to ........ off everyone who uses your header file, and doesn't want your choice of namespace.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Salem
    > ummm nevermind im an idiot, its late and i forgot my namespace
    Putting namespace into header files is a good way to ........ off everyone who uses your header file, and doesn't want your choice of namespace.
    How else would you std::istream
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid compiler errors
    By ChrisEacrett in forum C++ Programming
    Replies: 9
    Last Post: 11-30-2003, 04:44 PM
  2. ostream and istream
    By xddxogm3 in forum C++ Programming
    Replies: 2
    Last Post: 10-20-2003, 07:36 AM
  3. Error returning istream in class implementation.
    By joshdick in forum C++ Programming
    Replies: 8
    Last Post: 12-29-2002, 02:02 PM
  4. help debug overloading <<
    By rip1968 in forum C++ Programming
    Replies: 1
    Last Post: 05-02-2002, 11:45 AM
  5. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 03:07 PM

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