×

Loading...

it's a C language concept than C++

I think it will be narrower.
when a variable is defined outside any functioin, it is stored as static, no matter whether put "static" keyword before the variable.
If you put "static" before the variable, that means this variable can only be used within this .cpp file, cannot be used in any other .cpp file which even use "extern" keyword.

I guess the confusion is we usually use "static" within a function, in this case the "static" change the storage way of a variable from dynamic to static. this "static" is totally different concept as that "static" you mentioned.
Report

Replies, comments and Discussions: