Hello World

Hi guys!
Can someone help me: Please edit the program but not edit main fucntion. Make this code print like folow this:
1
2
3
Entering the Hello program saying...
Hello, world.
Then exiting..
.
1
2
3
4
#include <iostream>
int main(){
    std::cout << "Hello, world.\n";
}
Use global instance of a class. The constructor runs before main, and the destructor runs after main.
closed account (1v5E3TCk)
It is not easy without changing the main but you can do something like that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>

struct Notifier
{

    Notifier()
    {
        std::cout << "Entering the Hello program saying...\n";
    }

    ~Notifier()
    {
        std::cout << "Then exiting..\n";
    }
} notify;



int main()
{
    std::cout << "Hello world!\n";
    return 0;
}
Topic archived. No new replies allowed.