OOP Flashcards
What are function prototypes used for?
They are used to tell the compiler how the function was defined without having to write the function before the calling function.
By default when passing a value to a function in C++ is the passed argument a reference type or not?
By default the passed argument is a copy and not a reference
Can you set default arguments in functions?
yes just like in most other languages
calc_cost(double base_cost = 0.0.6)
Can I just pass an array to a function?
Arrays are pointing to its address in memory so a function has no access to the array size. The size needs to be passed to the function as well.
Also since the array is pointing to the original address the array is passed as a reference type.
How can I use pass by reference in C++
by using the ampersand we can pass by reference an argument to a function.
void swap(int &a, int &b);