Can anybody tell me the diff between keywords and identifiers?
Cin and cout in C++ are keywords or identifiers?

>cin and cout are none of those.
>They are objects.
cin and cout are identifiers referencing objects.

[cout<<] and [cin>>] are keywords since they are built by characters & have special meaning (i.e, these words are reserved for printing and accepting) in the headerfile [iostream]

[cout<<] and [cin>>] are keywords since they are built by characters & have special meaning (i.e, these words are reserved for printing and accepting) in the headerfile [iostream]

All keywords and identifiers are "built by characters", so I'm not sure what distinction you're trying to make here.

cout<< is neither an identifier nor a keyword, it is a combination of the identifier cout (referencing an instance of class ostream) and the operator << (a set of functions declared to be friends of class ostream, and defined as ostream & operator<< (ostream & ostr, const Type & val); for various type-values of "Type", and you can also add your own such functions to your own classes as well.

cin, cout, cerr, etc. have "special meaning" only in that they are declared in the iostream header (or possibly the ostream header for cout and cerr, and the istream header for cin) and connected properly to underlying file-handles for your convenience. They are in no way "reserved", and if you do not #include <iostream> in your file, you are free to declare them to be of any other type, and for any other purpose you see fit. Though doing so will likely confuse other programmers. Thus, they are meaningful only by consensus and consistent usage.

But regardless, welcome to the forum, ananyadiwas. And I sincerely hope I haven't scared you off completely!

This article has been dead for over six months. Start a new discussion instead.