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

Recommended Answers

All 8 Replies

identifiers and keywords

>>Cin and cout in C++ are keywords or identifiers?
look at the list of keywords in the link I provided, then you can answer this question yourself.

cin and cout are none of those.
They are objects.

The links are great though.

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

i think keywords are reserved identifiers

[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!

Here is a list of all c++ keywords -- notice cout and cin are not in the list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.