In general, function names have the same rules for variables, so they must begin with a letter or
an underscore and cannot contain spaces or other presentation characters yet.
So now I'm going to write some functions integer my function here an integer like my function.
And when we do the integer it is.
This is the illegal and the compiler compiler will or will not compile here will not compile.
Here.
And.
Uh, as I said earlier, they must begin with a letter or an underscore character and cannot contain
spaces, as you can see here, or other plantation characters, for example, like Toad comma here,
they cannot contain any punctuation characters for.
So following the general principle of self documenting code, you shall name the function according
to what it does.
So there is one exception, and these are the special functions used to provide overloads for operators,
which is mostly punctuation symbols.
So these functions have a name in the form here.
For example the multi here where the.
Mold is like describing the function which will will multiply the two values one by one.
So operators are one example of overloading here so you can overload any function that is used the same
name, but provide implementations with different parameter types or different parameter numbers.
We can make it like that.
For example, integer multiple.
We can make multiply.
We can multiply three numbers one by one.
Here, for example l h as integer or h as if you make it like that or just make it integer, for example.
Actually they will return the same value.
This is just a different writing in C++ here.
As you can see, we're going to get error because they are the two same function.
As you can see, the redefinition of multi, multi, multi are.
So if we make add another parameter integer x l x, we're going to make the overloading function here
and we're going to return the return the LCS multiplied by an error and multiply and multiply it by
the x h as here.
And if you make it like that, a standard c out.
See here and here, the mold, we're going to multiply.
We're going to call this here eight or 910.
So in this case, the multiply function will fill this court here.
This court will call this function because this takes parameters and where we gave this function to
parameters.
If you make it like that, this is going to call the the third function, the second function here that
we have three parameters and we are calling this function.
So and this named the function overloading here.
As we can see here, we multiplied the tree numbers one by one here.
So.
We have function parameters, the function here.
They may not have any parameters like this.
Here, for example, we can create a mute function, but with that parameters like this.
But they let us just create without parameters.
But we'll have the return value.
So in which case the case is the function is the fate defined with a pair of empty parenthesis like
this here, for example.
So a function, the function definition must give the type and name of the parenthesis parameters between
parenthesis like this here.
So.
In many cases, the functions will have a fixed number of parameters, but you can write functions with
a variable number of parameters.
So you can also define functions with the default values or some of the parenthesis.
So sum of parameters.
So in effect a providing a function that overloads itself on the number of parameter parameters passed
to the function.
So variable argument list and default arguments will be covered later in this course here.
We can also make the this specify the exceptions in C++ function here.
The functions also can be marked to indicate whether they will throw an exception.
So more details about exceptions will be given in next lecture.
But there are two syntax you need to be aware of.
So earlier versions of C++ allowed you to use the trough specified for.
Specified on the function three ways.
Firstly you provide a comma separated list of types of the exceptions that may be shown by code in the
function here.
And the second, you can provide an ellipsis like this here.
Ellipses or, uh, which means that the function may prove an exception.
And thirdly, you can provide an empty pair of parenthesis, which means that the function will not
prove an exception.
So the syntax here throw in exceptions to exceptions.
Rule looks like this, for example.
We're going to specify the exceptions.
For example, overflow of overflow error and.
Do we going to make, for example, do something which potentially.
May overflow flow.
So the trough specified has been deprecated in C++ 11.
As you can see, the compiler will say the dynamic exception specified for overflow of error is deprecated.
Consider using no accept false.
Instead here we can change ignore accept files so it froze specified has been deprecated in C++ is largely
because the ability to indicate that the type of function was not useful.
So however, the version of Shrove that indicates that no exception will be thrown was found to be useful
because it enables the compiler to optimize code by providing no code infrastructure to handle expectations.
Here are exceptions here, so the C++ 11 retains this behavior with no except specified and the Knox
except specified.
Here, we can delete it this false here and with no access specified, we're going to check.
Check the parameter and handle overflow appropriately.
Here.