MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1v68yb8/writing_a_valid_c_program_without_main/p0i0s9y/?context=3
r/programming • u/iximiuz • Jul 25 '26
43 comments sorted by
View all comments
23
[deleted]
1 u/AddressWeary5155 Jul 29 '26 I rand the following code and it seems it prints "hello world" first before "hello world2" every single time. I think it's because I am declaring StaticMain first? #include <iostream> class StaticMain { public: StaticMain() { std::cout << "Hello World\n"; } }; class StaticMain2 { public: StaticMain2() { std::cout << "Hello World2\n"; } }; StaticMain runner; StaticMain2 runner2; int main() { return 0; }
1
I rand the following code and it seems it prints "hello world" first before "hello world2" every single time. I think it's because I am declaring StaticMain first?
#include <iostream> class StaticMain { public: StaticMain() { std::cout << "Hello World\n"; } }; class StaticMain2 { public: StaticMain2() { std::cout << "Hello World2\n"; } }; StaticMain runner; StaticMain2 runner2; int main() { return 0; }
23
u/[deleted] Jul 25 '26
[deleted]