Inherit std :: ostream

I want to define MyOStream, which is inherited publicly from std :: ostream. Let's say I want to implement my own thread.

How can I do that? I will be happy for any help, an encoded example or any relevant link ...

thank!

+3
source share
2 answers

I do not quite understand what you are trying to do here. User code should not be inherited from the streams themselves, since the streams are intended to provide a generalized language conversion / installation of "streaming". If you are trying to use ostreamone that can write to a new buffer location (i.e. gzip stream), then you should usually inherit from basic_streambuf, which allows you to use existing iostream conversion tools, but allows you to redirect your input / output.

, iostream, , , IOStreams ++ . , ( ), , StackOverflow.

, , boost:: iostreams, , iostream .

+3
class YourStream : public std::ostream
{
public:
    YourStream() : std::ostream(pointer to your favorite buffer)
    {
    }
};

? Google , . this. .

0

Source: https://habr.com/ru/post/1781089/


All Articles