Course Content
C++ Functions
2. Function Arguments Specification
Positional and Default ArgumentsPassing Arguments by Value/Pointer/ReferenceChallenge: Banking Transaction FunctionConstant Function ArgumentsPassing Static Array as an Argument of the FunctionChallenge: Using Static Array as an ArgumentPassing Dynamic Array as an Argument of the FunctionChallenge: Why Do We Need Array Size as an Argument?Challenge: Passing Custom Structures as Arguments
4. Some Advanced Topics
C++ Functions
Challenge: Random Numbers Generator
Task
Let's create a function that will generate random numbers and return them as an array:
- Correctly specify function signature to return 1D dynamic array of type
int
. - Allocate memory for the 1D dynamic array of type
int
inside the function. - Return the function result in
main()
block. Specify the type ofrandomNumbers
variable to store the pointer at the first element of the created array.
Everything was clear?
Section 3. Chapter 3