Re: c++ basic question about ostream class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ranjith kumar <ranjithproxy@xxxxxxxxx> writes:

> Is this mailing list is for C questions only?

No.

> Can I ask a c++ question.

Yes, with the proviso that this mailing list is really for questions
about the use of gcc.  It's not for general language question.s


> using namespace std;
> using std::ostream;
>
> class myostream
> {
>         ostream &actual;
>
>         public:
>         int on;
>
>         myostream & operator <<(char *string)
>         {
>                 if(on)
>                         actual<<string;
>                 return *this;
>         }
>
> }
> int main()
> {
>         myostream t;
>         t.on=1;
>
>         t<<"HAI";
> }
>
>
> When I tried to compile above program I got  this compilation error.
>
> 1.cpp:2: error: ‘std::ostream’ has not been declared

This error message seems straightforward enough.  You have not declared
std::ostream.  This is normally done via

#include <ostream>

This kind of question is better asked on a mailing list about the C++
language, not one about gcc.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux