Content deleted Content added
No edit summary Tags: Mobile edit Mobile app edit iOS app edit App section source |
Tags: Reverted Mobile edit Mobile web edit |
||
Line 10:
Much of C++'s syntax aligns with [[C syntax]], as C++ provides backwards compatibility with C.
The C++ [["Hello, World!" program]] program is as follows (with additional comments explaining each line):<ref name="cppreferencehelloworld">{{Cite web|url=https://en.cppreference.com/w/cpp/io/println|title=std::println|website=cppreference.com}}</ref>
<syntaxhighlight lang="cpp">
import std; // Imports the standard library so that println can be used
/**
* @brief Main function of the program, defines the entry point of the program.
*
* @param argc Length of argv
* @param argv Array of C-style strings of command line arguments, where argv[0] is the executable name
*
* @return An exit code to the operating system, typically denoting whether or not the program executed successfully
*/
int main(int argc, char* argv[]) {
// Prints "Hello, world!" to standard output stream
std::println("Hello, world!");
// No need for an explicit return statement in main()
}
</syntaxhighlight>
|