c++ - how to create my own 'cout' and 'cerr' class -


how create own class behaves like: std::cout & std::cerr.

i writing mini operating system , requirement, having these modules there.

the code like:

mynewcoutclass mycout; // create cout behavioral class mynewcerrclass mycerr; // create cerr behavioral class  mycout << somestring << endl; // prints string mycerr << somestring << endl; // prints string error 

these objects std::ostreams. can create own std::ostream. precisely how that'll work depends entirely on data sink, haven't specified, std::ostringstream enough started on testing code uses it.

however, if literally wish reinvent std::cout, don't. data sink magic file handle stdout, can't recreate it's provided os. create std::ostream steals buffer std::cout what's point?


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -