#include // Why does this source code not compile? // // First, examine the code and try to // identify the problem without compiling it. // // If you cannot find the problem, compile // the code and use the compiler's error // message as a hint. // // If you still cannot find the problem, // scroll down. // Function declaration int main(); // Function definition int main() { std::cout << "Hello World!" << std::endl return 0; } // The statement // // std::cout << "Hello World!" << std::endl // // must end with a semicolon: // // std::cout << "Hello World!" << std::endl; // // Without the semicolon, the compiler treats // the next line as a continuation of the same // statement. It therefore effectively sees // something like // // std::cout << "Hello World!" << std::endl return 0; // // which is not valid C++.