Professional Documents
Culture Documents
In C++ we can tell the compiler to use default values if the arguments are not supplied.
Indicated in the function prototype
107.Overloading functions(Polymorphism)
We have functions that have different parameter lists that have the same name.
Using the same name for various forms of that same functions
The value of the name of an array is the location of the first element of the array.
The array was never copied! instead the address of the array was passed in.
If you have access to the actual and don't want to change it, const is the way to go!
109.Pass by reference
In order to be able to change the actual character parameter from within the function
body. In order to do this we need the actual address of the parameter.
Complex data that is defined outside a function: pass the data by value or using
pointers.
120.Dereferencing a Pointer
Process to access the data that a pointer is pointing to.
Dereferences operator *.
The allocated storage doesn't have a name, the only way to get to that storage is via
the pointer.
Using delete to deallocate storage. Delete keyword followed by the name of the
pointer.
Pointers to constants
The data pointed to by the pointers is constant and cannot be changed. However
the pointer itself can change and point somewhere else.
Constant pointers
The data pointed to by the pointers can be changed. However the pointer itself
cannot be changed and point somewhere else.
Since the parameter of the function is a pointer to an integer, that means is expects
an address of an integer.
int main(){
int value;
double_data(&value);
type *function();
int *new_storage{nullptr};
new_storage = new int[size];
We can return a pointer from a function if we want to get the address of and structure
allocated on the heap. Doing so, we don't lose the key to the elements on the heap
Uninitialized pointers contain garbage, it can point into an important area in memory
and we can whip it out.
128.What is a reference?
It is an alias for a variable.
Cannot be null