[CSI] main is not a keyword

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Feb 13 23:38:25 EST 2022


CSI students,

This is regarding the question asked in class last time.

- (reserved) keyword is an indentifier with a special meaning to the
  compiler. It is not available for re-definition. For example: if,
  else, case

- predefined identifier is similar to keywords, but may be
  re-defined. Examples: main, endl, cout

  As an example demonstrating the difference, the following code
  compiles:
  
--------------------
  #include <iostream>

  using std::cout; using std::endl;

  int main(){
     int main=55;
     cout << main << endl;
  }
--------------------


Thanks,
-- 
Mikhail


More information about the cs13001 mailing list