Hello I've been asked to write a C++ program with an empty main function body but the program should print: "hi there!"
.
So I've done it this way:
#include <iostream>
struct Foo
{
Foo(){std::cout << "hi there!\n";}
}fobj;
int bar()
{
std::cout << "hi there!\n";
return 0; // arbitrary value
}
int x{bar()};
double pi = (std::cout << "hi there!\n", 3.14);
int main()
{
}
The output:
hi there!
hi there!
hi there!
It looks it works fine from my codeblocks but on my phone using "Coding C++" it says: process terminated. signal 11
.
- So is all my case are well-defined or there's something disastrous? Thank you.