Is it possible to instantiate an object of a class even before main() executes? If yes, how do I do so?
Global objects are created before main()
gets called.
struct ABC {
ABC () {
std::cout << "In the constructor\n";
}
};
ABC s; // calls the constructor
int main()
{
std::cout << "I am in main now\n";
}
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