Now we can move to next topic or this binder, so this binder is something which we use to hold the
address of current object.
So suppose we want to access something inside a class.
You need to call that address of that particular current object, which is in action right for that
purpose we use in this binder.
So let's see a quick demo.
What this is all about.
The demo theory is not much important, so we can go to this point US program here, right?
Opiod able to see it.
Now, if you look into this program, there is nothing much to see.
There's a class named demo created.
It's having private access to labor and I'm getting to where it was number.
And see, it's created for that and we have a public access.
Specify it.
Then I'm writing my function inside that class in that case, so you can write the function.
Also, you can define it inside a class.
So this index is very simple.
You can use this index for the function.
Again, write this index and you can start the definition of the function, how you can access this
function object of that class.
Not set my values.
OK.
And that's all things seen with respect to functions.
And here what I'm doing.
whoI set my values.
I'm creating that function.
It will have ability to get to arguments that is numb and see it.
And it's showing this.
I don't know, I'm equal to.
So, you know, here, this is that this point I was talking about why it's using that.
Because this num and see it's private variables, as you have learned in the previous section of access
specify it's private variable scan or the variables which comes under the private access label can be
or lean's access inside the class.
So we are trying to access this node and this see, it's inside this class itself.
So this bind us sees this dark number to know this darkness.
That means this one equals to number.
That means this what you are getting, that this is that dual variable with just local to the function
number.
And see, it's and it's like, this is that two variables inside the glass more that having the same
name.
How we can differentiate that.
So this keyword is used for that.
So this behind us says that this number will be the number which is defined for that class.
And without this number, it means like the local variables for the function.
So it's very simple.
Even that Visual Studio code is showing that this c the example.
If you are clicking on this dark number, it is actually highlighting this one, right?
And if you are creating on this note, it's highlighting this one.
So you can differentiate What is this?
I don't operate that a number and this ad override that see, it's more different.
This is winding to this and this is why into this.
So this binder will be pointing to the current class.
And if you are using this behind it, it will get the current class variables or functions.
OK, now another function is return for displaying the values.
It's straightforward, and now we are going to the main function.
Yeah, creating the object for the more class we are setting values of object with hundred and eight.
So what happened?
Object named dock function name will guide this function or here it will pass and led to here and to
hear what happened to the next step.
That object, our demo object, it's the become the value from here and objects associates will become
the value from here.
So that's it.
And I am granting that display values just getting that values from the class or object and just printing
it out.
It's a straightforward function, just use for printing them out.
Now we can just run this.
So C++, this b dog.
No, I'm going to run this.
I have compiled or slash it out, and I am going to send this very straightforward.
It's showing a hundred and eight.
That's it.
That's down.
OK, now let's go back to our PowerPoint next stop.
Biggest private functions and friend classes.
So you have already we have seen this thing right, how we can use access.
Specify this and this point, and you have a conclusion that how you can access the private and protected
data members of the class because you need to always access the data private data also right?
If even if that data is declared as limited or under private access label, it should be accessed.
If there is no access outside the class, there is no meaning.
Right?
So in order to overcome the limited private members not being accessed outside the class, we will use
that concept art, front function and free classes model for same purpose.
We declare private function inside a class so that the private and protected data members of a class
can be.
Sensed and seen that Israel is in a uniquely reckless and inside that you will name that function by
you and your psyche, you are right this keyword for like your friend will be used to make that function
from function.
So how that you see here, you have an example.
Clear example.
So we have a glass glass.
So this is about creating a frame glass.
So if you want to create a Class B, which is a premium glass of air, you have to redefine Li.
Like you have to make the compiler understand that the glass beads are already dead.
So that's why we are declaring glass glass.
Be here.
Then we are creating glass.
Then you have to say like Frank Glass be.
This just means like glass.
We will be glass glass.
Then you will define that glass.
So if you declared that Cosby asked, the glass is then glass, we will have access to all that data
members and fountains of that blast.
So these are like two different topics.
One is brain function and Frank Glass.
So both are similar framing function.
If you declare a function as a friend to a glass that function, we have access to that glass, private
and protected data.
Similarly, if you declare glass front line of that glass, the front glass will have access to that
all that private and protected data members of that particular class.
Now let's jump to that demo.
So here we have the example of frank functions.
So you can see I have a glass name distance and it's having a data.
This is the part where you have to focus.
It's having a variable card meter, which is declared as private.
So there is no way to access this variable meter outside this glass because it will be throwing out
an error.
So what I am doing, I'm creating a program function.
So Edison brings the function declaration form and should be there.
Along with that, you will be saying upfront from keyboard in front of that.
So it will become a function, then I'm having a public glass distance meter of zero.
This is actually I can stick to this topic.
We will be covering later so you can enter this one.
You can just focus on here.
So I'm trying to create that definition of different function.
Add five distance.
The exact five is that foreign function.
So it's able to access that meter.
OK.
He told me that it will not any add up because this is our different class of our class.
So differently that is possible plus equal to five.
What does this mean?
Speed dog meat recall two plus equal to five means be dark meat less white.
That means adding the value five to the may be dark meat.
So what is the current value which is inside this meat?
It will be.
This function will be adding five to that, then returned dark meat.
So now here we are declaring distance D. So you can see this stems made of zero.
This means that the value of meat will be set to zero.
So this is that I'm stricter and stricter will set the value of me down to zero.
And second, we will study in detail.
But no, you just need to understand this.
This statement will make that value meter of the object being created out here equal to zero.
So see at our press maybe three to five that we know.
So what happens when you can't add five of B and five will be actually sending out the value of that
object inside my friend function.
So it will accept that object inside my private function and it will access dot meter plus equal to
fight, which means it will add the value of meter plus frame.
So current value of meter is zero and it will add five.
So it will be then so will be quite so.
We are counting that and try it again.
Let's see this in action again.
Plus plus key word from func not see now, not slash and outright fire.
So you have some confusion here, right?
So let me show this just to zero.
The current value of media when that object was created was zero because yet I have lost that value.
So let me put it, despite what happens to this program, you can see that so five and I have asked
that act function by function would be executed.
So if I will be there?
Now what happens?
You can predict output comparing and then bringing that was centered 10, right?
Because here the value was five.
Then you have add five to that value it become.
And the point is we have ability to access that private, private data member that is meter from the
front function.
So that's why we use that function.