This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++ basic question about ostream class


ranjith kumar <ranjithproxy@gmail.com> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]