Why is argc not a constant?

后端 未结 7 568
时光说笑
时光说笑 2020-12-07 21:58
int main( const int argc , const char[] const argv)

As Effective C++ Item#3 states \"Use const whenever possible\", I start thinking \"why not make

7条回答
  •  忘掉有多难
    2020-12-07 22:09

    argc is not normally a constant because the function signature for main() pre-dates const.

    Since argc is a stack variable, changing it won't affect anything other than your own command line processing.

    You are, of course, free to declare it const if you want.

提交回复
热议问题