From 3a42126eded15520e6cbe2306fbe114c4b04500b Mon Sep 17 00:00:00 2001 From: Lucas Rufkahr Date: Mon, 2 Mar 2026 14:32:04 -0600 Subject: [PATCH] update functions page --- content/cpp/.functions.md.swp | Bin 12288 -> 0 bytes content/cpp/functions.md | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) delete mode 100644 content/cpp/.functions.md.swp diff --git a/content/cpp/.functions.md.swp b/content/cpp/.functions.md.swp deleted file mode 100644 index 2284be31c9ae4862a13a1d53a3fed69b6d292329..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&O-|cD0EXd#H7E!!U_io)$gy$wjl`CU1q%wHrIeqEGfqs5?T*Jlqzd+2peNuC zJwz|iGxQ2w^s@<4g_LH{XY-UQC<^gOG3m& zAah-W1KHQ*?bnWh%3`IRxY3h(m?+aob?>FIxBoBbeu#{FtvY#RlpCapQHgPbEOWym z2~3nGdE>JC(klFp1z2G00)+{kjp=sNU-rtmiwpDC+-!U7WjKKaSbzmsfCX591z3Ou zSm6B@FxiB-!{bkme!|q~Jn`&2y5xxkSbzmsfCX591z3OuSbzmsfCX6K9Tt$-W3ShQ zz?Oft|Nr#=|1Yk8!!P&=5AXx-;XB;GHC#bCSHm~RAcX`jA%+25Km>j0K?n-E5I_ec zoWmKM!U=qZWB39`@EJbAA++HD_TeM!0S^{n0Ty5Z7GMDuU;!3j0Ty5Z7I-5C7A-tT zyB(=7zrZBRXYS_|4YpdTYgZytS6++0`@r17tpG=>Px# diff --git a/content/cpp/functions.md b/content/cpp/functions.md index c36b05d..1214143 100644 --- a/content/cpp/functions.md +++ b/content/cpp/functions.md @@ -8,3 +8,29 @@ tags = 'cpp' chapterno = 3 +++ +## Documentation practice + +It is a good idea to include comments along with the functions you create and should only be put within the function prototype. They should include: + +- A brief description of its purpose: +- Precondition: + - The conditions that are required in order for the function to work properly. +- Postcondition: + - Only include if the final result of your function is difficult to understand by reading the code. + +Make sure when creating comments, do not state the obvious. They clutter your code and make it more difficult to read your code. Only include comments to things that are complex or difficult to understand. + +Example: + +```c++ + +// Description: Returns the square of a number. +// Pre: Size of x must be less than size of int when squared. +int square(const int x); + +int square(int x) { + return x * x; +} +``` + +Function abstraction is the ability to make a function easy to use without understanding exactly how the function works line by line. This makes it easy for other people to use your code faster. It is a good practice to make your code easy to use for other people.