#include #include #include "fork.h" class Daemon: public Fork { void parentProcess() override // the parent does nothing. {} void childProcess() override // actions by the child { sleep(3); // just a message... std::cout << "Hello from the child process\n"; throw 0; // The child process ends } }; int main() try { Daemon{}.fork(); } catch (...) {} /* Generated output: The next command prompt, then after 3 seconds: Hello from the child process */