I have a global object which is declared before main function and a static object inside main.
A obj1 is also called static; why is that? class A { ... };
A obj1;
int main()
{
static A obj2;
}
obj1 has static storage. It will be initialized when the program starts.
obj2 also has static storage because you said so. It will be initialized when main() executes the first time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With