Mike Szer Mike Szer - 1 month ago 17
C++ Question

Time complexity of C++ cout?

What is the time complexity of making a

cout <<
in C++?

If I have a
cout
in a loop, for example:

for(int i = 0; i < 1000000 ;i++){
std::cout << i << endl;
}


Without the
std::cout << i << endl;
would it be much faster the loop?

Answer

Time complextiy of Cout<<:

It completely depends on what type you are printing, how you overload your "operator<<", what operations you are doing inside "operator<< overloaded function.

ostream& operator<<(ostream& os, const "yourType"& T)

second question: Yes. Obviously. "Jon Trauntvein" provided good info on it.

Comments