1.1 KiB
1.1 KiB
Example markdown
Compare the processed version of this file with its unprocessed form.
The includes
The includes are important to tell the compiler what to expect later. In the example file, the includes are :
#include <iostream>
#include <factorial.h>
The factorial function
The factorial function is implemented recursively. It is defined in another file called factorial.cpp :
int factorial(int n) {
if (n <= 1) {
return 1;
}
return factorial(n-1) * n;
}
The corresponding header file is :
#pragma once
int factorial(int n);
Some other function
Some other function is implemented in the example_code.cpp file.
While the snippet is defined in the C++ file, we can decide to not use it in the documentation.
Main function
In order to call all the functions defined above, the main function is implemented as such :
int main() {
// Call the factorial function
std::cout << factorial(5) << std::endl;
// Call some_function
std::cout << some_function(3) << std::endl;
return 0;
}