Now, let's focus two more concepts nested class and in a class, and we're going to need them later
on.
So let's look at the concepts here.
A class which is created inside another class and a class which is created inside another class with
the key word inner.
So this is the difference between the two, but there are a little more differences that we need to
look at.
So let's look at the master class.
First in the class is such a class which is created inside another class in Scotland.
An asset class is by default static.
So its data members and no functions can be accessed without creating an object of the class.
So without having to create an object of this nested class, you can go ahead and use the functions
and members.
Then the asset class cannot access data on members of the outer class, so it's a one way relationship.
So only the poorer class can access the members of the master class, but not the other way around.
So let's look at this we have a class called our class, and then inside of this class we create another
class called master class.
OK.
And usually you should create classes which are separated so each having their own file.
But sometimes it just makes sense to have a nested class.
For example, if you really just need it's functionality within the upper class that we're using here,
and this is class example that we see here is that we have this other class and there we have a variable
called name.
And it said that to Mr. X.
And then we have this business class, which has a description, and then it has an ID, which is of
type and at a function called Foom, which just prints the name and the ID.
And then we go to our main function where we try to access the description.
So in order to access the description, we go to our outer class and then inside of that, we go to
the nascita.
So we're accessing the property here, and then we create an object of the asset class and we access
the function.
So the function of that master class.
So the output is code inside the NSA class and it is one on one.
So now let's look at the inner class concept, and in a class is a class which is created inside another
class with the keyboard inner.
In other words, we can say that the NSA class, which is marked as inner, is called an inner class.
So it's still an asset class, but it has this additional keyword, right?
But the difference now is and in a class cannot be declared inside interfaces or in asset classes.
And the advantage of in our classes is that they are able to access members of its outer class even
though they are private.
So this is a huge difference, right?
So the inner class keeps a reference to an object of its outer class.
So if you look at this example here, this is the syntax of an inner class.
So we have the upper class and we have dismissed the class, but we add the inner keyword.
So in there just before the class keyword?
All right.
And then if we look at this example that we had before.
The only difference now is that we add in a keyword here to our in a class and that we now can access
name and ID.
We could, of course, beforehand access the idea anyways, but we couldn't access the name.
So you can see here the name that we're using is from the outer class.
So here where we have this private keyword, even so, we say, OK, this is private, so it should
only be available within this class.
But with the inner classes, you actually have access to even private class members of your class.
OK, so that's the huge difference in an asset class without this inner keyword.
This wouldn't be possible.
So sometimes it just makes sense, and sometimes you just need this functionality and then you make
it into the class and you can use it.
So going back to our function mean here we have our outer class in our class description so we can access
the property as we did before and can also access the object form.
So we'll create an object of that in our class, which is inside of our outer class, and then we can
go ahead and use its member functions.
So the output here is code inside in a class name is Mr. X, and it's one one.
So we didn't have this name is Mr. X before.
All right, so that's it for now.
Let's get back to ccording, where we are actually going to use this functionality and then we'll make
a lot more sense because it's a little bit abstract to look at it that way.
So let's get into coding.