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
Sign in to Reply
  1. j.smith1981's Avatar
    • Full Member
    • Location: UK
    • Posts: 101
    Re: C++ questions
    (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.
    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.
  2. Psyk's Avatar
    • TSR Royalty
    • Location: Leamington Spa
    • Posts: 19,071
    Re: C++ questions
    (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.
    cout is actually an object itself

    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.
Sign in to Reply
Share this discussion:  
Useful resources
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.