Cout and Cin is an object of which class? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grátis
+ 3

Cout and Cin is an object of which class?

I tackled one question in a challenge... that The 'cout' is an object of which of the following classes? a) iostream b) ostream c) istream d) ifstream the correct answer given was 'ostream'? please explain me if cout is a class of ostream (not iostream) then why don't we include ostream while writing simple program like 'Hello World'? similarly, please tell me 'cin' is an object of which class?

30th Mar 2018, 4:06 PM
Suraj Jha
Suraj Jha - avatar
4 Respostas
+ 16
std::cout and std::cin are globalobjects of classes std::ostream and std::istream respectively, which they've overloaded operator << and >> . You should read about operator overloading. cout is object of type ostream.  cin is object of type istream. To use both we use iostream iostream -> input/output stream istream -> input stream //cin belongs ostream -> output stream...//cout belongs
30th Mar 2018, 4:12 PM
🌛DT🌜
🌛DT🌜 - avatar
30th Mar 2018, 4:32 PM
🌛DT🌜
🌛DT🌜 - avatar
+ 3
🌛DT🌜 please tell me... does it mean when we include iostream... we indirectly includes istream as well as ostream at the same time?
30th Mar 2018, 4:28 PM
Suraj Jha
Suraj Jha - avatar
+ 1
thank you so much bro..☺
30th Mar 2018, 4:31 PM
Suraj Jha
Suraj Jha - avatar