This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: c++ basic question about ostream class
- From: Ian Lance Taylor <iant at google dot com>
- To: ranjith kumar <ranjithproxy at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 27 Mar 2009 18:03:13 -0700
- Subject: Re: c++ basic question about ostream class
- References: <31cff80d0903271500r4fbde54dkbcf98b2009e80139@mail.gmail.com>
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