C++ is not a superset of C.
For every C++ program, there exist one or more functions, one of which must be named `main`.
int main() { return 0; } // It won't do anything, but it will give you a 0.
Below is the structure of a function.
return_type function_name(parameter_list - it can be empty) {
// function body
}
Regarding compilation, take my TDM-GCC compiler as an example.
g++ treeinmyhouse.cpp -o thetree// generate thetree.exe gcc treeinmyhouse.cpp -o thetree// generate thetree.exe, and libstdc++ won't be automatically linked. g++ Random/treeinmyhouse.cpp -std=c++20 -Wall -Wextra -g -o Random/thetree// -o: output treeinmyhouse as thetree in Random folder // -g: generate debugging information // -Wextra: More warnings // -Wall: Common Warnings // -std: Specify C++ standard, to C++20(2020) version - more - // -O2: optimization
Enter my practice set
Into the - Standard Library -
Input and output are handled in the standard library iostream -
Into it -