0

Cout copy

Hi Can we create copy of the cout object? Why?

23rd Sep 2024, 3:33 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
5 odpowiedzi
+ 2
Ketan Lalcheta do you mean something like this 🤔 https://sololearn.com/compiler-playground/cOo4nUuu8W9p/?ref=app
23rd Sep 2024, 3:39 PM
BroFar
BroFar - avatar
0
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
23rd Sep 2024, 5:59 PM
Sharpneli
Sharpneli - avatar
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
23rd Sep 2024, 6:25 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
Sharpneli why it is designed to have only single object ? Any specific logic to avoid more objects ?
23rd Sep 2024, 6:26 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
If cout can be copied, then there is duplicate buffers and many stream copied. Not good for performance
23rd Sep 2024, 6:28 PM
Sharpneli
Sharpneli - avatar