Noob question about scope.

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Noob question about scope.

Post by albinopapa » November 1st, 2017, 9:39 pm

static has a few meanings though, all stored in static memory, but in a function it's scope is still in the function. In class it's basically global, but can be hidden as a private member. In header, it is global, not sure why they say static is file scope when it can be seen and accessed by any translation unit that includes that header. Only way to get file scope is a global atop the cpp file.

I guess it also kind of depends on what you mean by scope. Where it can be accessed? Having to use the scope resolution operator (::) or when a destructor is called? If it's the last one, then namespace, file and static are all global since memory won't be freed and destructors won't be called until the program ends.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply