← C++ Programming learning pathC++ Programming · Module 3 of 10
Control flow and functions
Make decisions, loop and organise code.
📖 Key ideas
- if/else, switch for decisions.
- Loops: for, while, do-while, range-for: for (int x : v).
- Functions: int add(int a, int b) { return a + b; }
- Pass by value copies; pass by reference (int& x) shares.
- Function overloading: same name, different parameters.
💡 Real-life example: Pass by reference is giving someone your notebook; pass by value is giving them a photocopy.
Range-forLoop over each element
Pass by referenceFunction works on the original
OverloadingSame name, different params
Return typeType a function gives back