Static variables in C and C++

前端 未结 5 1224
天涯浪人
天涯浪人 2021-02-07 08:33

Is there any difference between a variable declared as static outside any function between C and C++. I read that static means file scope and the varia

5条回答
  •  攒了一身酷
    2021-02-07 09:02

    There are two concepts here "static linkage (or scope)" and static allocation".

    Outside a function the keyword refers to linkage, inside it refers to allocation. All variables outside a function have static allocation implicitly. An unfortunate design perhaps, but there it is.

提交回复
热议问题