"is protected within this context"

I wrote the function, printOut
with prototype...
1
2
3
4
5
6
7
8
9
10
11
12
13

    ostream *printOut(ostream out , char * output);

and implementation...

    ostream * printOut(ostream out, char *output) {
    int counter = 0;
    do {
        out.put(*output);
    } while (output[counter] !='\0');
    return &out;
}

And im calling it like this...
1
2
   char error[] = "Too much Data";
                printOut(cout, error);


However, I'm getting the error

 
error: 'std::basic_ostream<_CharT, _Traits>::basic_ostream(const std::basic_ostream<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' is protected within this context


But I'm not sure how to make a function, that's not in a class, not protected, nor do I understand how it being protected has any effect on it.
Last edited on
You're not allowed to make a copy of cout (or any ostream), so you can't pass it by value.


Last edited on
Topic archived. No new replies allowed.