static object of class

hi all.i am new in C++.
what is goal to determine static object of class?what is diffrnce with usually mode?
for example :
#include

static class* KALA;
int main() {
.
.
.
}
class is a class and KALA now is obejct

thank all.
A static variable is actually a global variable. There is a minor difference: static variables are not linked. I.e. you can use the same name in different compiler units/.cpp with static.
@hadisamani1996, KALA is not an object.

It is POINTER to a "class", but it is not an instance, it has no storage. It is also uninitialized.

1
2
3
class T {};

static T KALA();

Now, KALA is an instance, an object.

static T * KALA = nullptr;
Now, KALA is a pointer to a T, but at least it is inialized to nullptr



Last edited on
wouldnt a static global pointer be zeroed and therefore nulled?
@jonnin - it should be, but....

There are situations I've encountered where a dynamic library is loaded unitialized on certain platforms. Indeed, one of the "issues" with dynamic libraries is that objects aren't initialized by calling constructors when in global scope. I would expect such pointer to be zeroed, as you do, yet you must admit, it LOOKS uninitialized, and it's just comforting to see it explicated.
Topic archived. No new replies allowed.