C++ questions
From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.
| Announcements | Posted on | |
|---|---|---|
| Enter our travel-writing competition for the chance to win a Nikon 1 J3 camera | 21-05-2013 | |
-
Re: C++ questionsThe way objects are usually called is with the objects name and then call a function from the class.(Original post by INTit)
It's a class with a templated, overloaded '<' operator which allows access to the output stream. Ok maybe there's a good reason tutorials don't go into too much detail explaining cout lol.
Putting the cout object as a template stops you from having to put the object name and then calling the function to make this work, allowing you to just use the word cout and not having to call it from a object reference if that makes any sense? As far as I understand this of course. -
Re: C++ questionscout is actually an object itself(Original post by j.smith1981)
The way objects are usually called is with the objects name and then call a function from the class.
Putting the cout object as a template stops you from having to put the object name and then calling the function to make this work, allowing you to just use the word cout and not having to call it from a object reference if that makes any sense? As far as I understand this of course.
http://www.cplusplus.com/reference/iostream/cout/
It's an object of type "ostream". In the ostream class the "<<" operator is defined which is basically equivalent to a function but with different syntax. There are different versions (overloads) of this operator for different data types.
The implementation of the ostream class may use templates, I'm not sure. But if you're just using it you probably don't need to worry about how cout is implemented.