0
Cout copy
Hi Can we create copy of the cout object? Why?
7 odpowiedzi
+ 4
Ketan Lalcheta do you mean something like this 🤔
https://sololearn.com/compiler-playground/cOo4nUuu8W9p/?ref=app
+ 3
If cout can be copied, then there is duplicate buffers and many stream copied. Not good for performance
+ 3
maybe something related to this?
https://stackoverflow.com/questions/55573371/logging-stdin-and-stdout
+ 1
No you cannot copy any object defined in the istream or ostream because only one instance of them must have in your program
and in their class, you will see that the copy constructor has been deleted if you look at the cpp source code
+ 1
No, you cannot create a copy of the cout object. The cout object is an instance of the std::ostream class, which is part of the C++ Standard Library. Stream objects like cout are designed to manage output streams and are not meant to be copied or assigned. This is because they manage resources such as buffers and file descriptors, which can lead to complex issues if duplicated. https://www.my-labcorp.com
0
BroFar need to understand that code first. Thanks for sharing it. Will take a look.
I thought to have copy of cout in << operator overloading
0
Sharpneli why it is designed to have only single object ?
Any specific logic to avoid more objects ?