There are situations when you have one or more parameters that have values that are so frequently used
that you want them to be treated as a default value for the parameter.
So while still having the option of allowing the color to provide different value if necessary.
So to do this, you provide a default value in parameter to the parameter list of the definition here.
So let's let's make the void here.
Make the function named log message here.
First is const string here message.
Of course, we have to include the string k change string to.
Yeah, we have to.
Include include string and.
We'd have to losing namespace CB.
Stay here.
And then we're going to create another bowl here.
And we'll clear the screen.
And we're going to equal to false here.
As you can see, this is the first time we use the initial self initializing parameters in this course
year.
So and we're going to add the if the clear screen is true, then clear the clear the screen here, which
we're going to write it here.
Okay.
Uh, void void clears the screen screen.
Yeah.
And we're going to call the clear the screen.
Clear the screen function here if the clear screen returns true.
So in most cases, this function is expected to be used to print a single message.
But occasionally the user may want to have the screen cleared first, say for the first message or after
a predetermined count of lines.
So to accommodate this use of this function, the clear screen parameter is given the default value
of false here, but the color still has the option option of passing a value here.
So now we're going to print the message here, Kay, like this print message here and and the line.
And in the main function, let's call this log message function here and write our message first message
here.
And then we're going to pass the through here.
And let's create another message here.
This is the second message here without the without the second parameter bool parameter.
As you can see, if you made this differently, like if we delayed this, as you can see, this message
gives error because the compiler knows if we don't have the second parameter, then the full clear screen
has to be false and we're going to like abstract virtual.
We're going to have the virtual seven second parameter.
If you call that like the real world applications here.
So.
Here.
We're going to add another.
We're going to create a pool here.
So we're going to pass the user decision.
And here.
We're going to hear, for example, it's the you let's make the user decision.
True.
And we're going to log message here.
Log message that third.
Sir, the message here and we're going to pass the user decision as the variable here.
That's okay.
So.
Not that the default values occur in the function, not in the function prototype here.
So if the log message function is declared in a header file, the prototype here should be like like
the external.
Here we're going to have the extend.
And without this braces here, we just have to write the parameters of our function.
So if we call this function with X, then as you can see here, we're going to get the error here,
but let's delete it.
Oops.
Uh, what's the problem here?
We have the.
Clear the screen.
Yeah, We have to make it.
I'm right here.
Here.
We're going to comment this up because this is the program of Lex lecture.
And as you can see, the compiler showed the tells that we have the problem here.
And we're going to firstly on the find the reference to clear the screen here.
So now we just we're going to know we're not going to using this function for now.
And we're going to delete that.
And as you can see, we show the message on it here.
So.
Let's play this as well, like this here.
And as you can see here, the first message, second message and third message printed here.
And as you can see, the second in the 10th line, we didn't enter the second parameter.
That's why the second, if we don't enter the second parameter, the compiler expects us that the second
parameter is false here.
So if we don't enter the second parameter, the second parameter will be automatically taken as false
here.
So actually you can treat the each parameter with the default value as representing the separate overload
of the function.
So conceptually here the log message function should be treated as two functions.
As I said earlier, so if you if you define a log message function that has just a constant string parameter
here, then the compiler will not know whether to call the function or the version.
The clear the screen is given a default value of false here.