‫Welcome back.
‫And this video I would like to talk about members and therefore, I just create a new class here and
‫I'm going to call it members.
‫Now, in this member's class, I want to go ahead and create all the different types of members that
‫are relevant when working with object oriented programming.
‫So we have private fields, for example.
‫So let's call a member private field here, and that would be something like private string
‫member, name ten private string job title.
‫So these are just examples of members.
‫So they can be private fields, they can also be public fields.
‫So remember they called member fields, so.
‫This would be public field and that's public int h.
‫So just as an example, right, then a member could have a salary.
‫All those kind of things.
‫So all of these variables, these fields, these global variables, they are members of this class members.
‫So then there are properties which are also members.
‫So let's say I want to have a property, I'm just going to prop here and then double tap and I get this
‫property and it's going to be the string job title.
‫Job title.
‫So we have that here, which was a private field and now I create a property with the same name, but
‫with a capital J.
‫And in here we have a getter and setter, and they are also created, automatically created.
‫But we can also go ahead and create the manually, as you have seen in the last video.
‫So let's just do that real quick.
‫So instead of get and set with the standard here, I want to get I want to return the job title and
‫instead of a standard setter, I want to use something like job title should be set.
‫So job title is going to be the value that is given to us.
‫All right.
‫So that's our get set and let's clean it up so that it looks a bit better.
‫So this is a member property which exposes job title safely and generally.
‫So, you know, just remember properties start with a capital letter, then we have a member which is
‫a method.
‫So let's create a public member method which can be called from other classes.
‫As you know, with public methods they can be called from other classes and methods within a class are
‫called her members.
‫So the members class.
‫In our case, this is a class called members, but whatever the name of the class would be, so let's
‫say it's student.
‫So you have a class with all of your students, all the information about students and the skills of
‫students and so forth.
‫Then a method in there would also be a member.
‫So let's just create an example.
‫Public void intro juice thing and bool is friend.
‫And what I want to do in here is simply introduce someone and if it's a friend then I want to introduce
‫myself in a, let's say, more private way or something like that.
‫All right.
‫So let's say we have just a different another one.
‫I'm going to add another field here, which is going to be a celery.
‫So private and celery.
‫And now if it's a friend, I want to tell them about my celery as well because I wouldn't share that
‫with somebody else.
‫But instead of using a public method, I'm going to use a private method for that.
‫So I don't want to do that within the introducing itself.
‫I want to create a different method for that and it's going to be private void sharing private info
‫and it's going to write something like, hi my well actually just call my celery.
‫My celery is the celery.
‫Now, of course, we need to know the celery or there has to be a celery value.
‫So let's just set that as a standard value.
‫So minimum 20,000, that's how much our members minimum celery is going to be.
‫So that's going to be the shared private info and I use this bool is friend whatever introducing is
‫called to call sharing private info or not so if is friend then I want to call share private info.
‫Otherwise I'm just going to write something like.
‫LS CW Hi, my name is Curly Brackets zero and my job title is Curly Brackets one and then I'm Carter
‫Brackets, two years old.
‫And now we of course need all of this information.
‫So the one was the member name.
‫Then we had the job title and we had the H.
‫So all of those are given if somebody is not a friend because our friend would usually know these kind
‫of things, our job title member, whatever.
‫But if we want to introduce some new information to our friend, it's going to be something like my
‫salary.
‫Well, it's just an idea that I came up with that's private that I wouldn't tell somebody on the street
‫usually.
‫And then we even have a different member, which is a constructor.
‫So a constructor is also a member.
‫So if I create a member's constructor here, this is going to be a member.
‫So the constructor is a member console right line and it's going to be something like object created,
‫very simple.
‫So whenever a member is created, we simply have this object created.
‫And what we also should do in here is because we don't have any values for our member name, job title
‫and salary.
‫Actually, we can get rid of that salary here and we're going to initialize it just in members.
‫So we're going to say H is going to be, let's say 30 then member name is going to be Lucy.
‫Then we have the salary and Lucy earns a great amount of $60,000 or euros, whatever you like.
‫And then we have what else do we have?
‫So we had salary member name, job title.
‫So what's her job title?
‫Let's say she's a developer
‫and we're not going to go into detail what type of developer she is, but that's our members constructor.
‫And the constructor itself is a member of this class.
‫And finally we have something called Final or Destructor, which is also a member, and the destructor
‫is created with this curly sign here, and then the name of the class, which is a members or which
‫is members simply.
‫And this final user or destructor cannot be defined in structs.
‫It's only possible to do that within classes and.
‫A class can only have one final loser.
‫So we have seen that we can create multiple constructors, but we can only create one destructor per
‫class and that final sizer cannot be inherited or overloaded and it cannot be called.
‫So it's only there for this specific class.
‫So whenever the object runs out of scope, so our members object runs out of scope, this file analyzer
‫will be called and let's just create one.
‫By the way, it's there for clean up statements.
‫So only cleaning up is useful here.
‫And let's just write something onto the console, something like deconstruction of member object.
‫So whenever the object is closed or deleted or runs out of scope, that's when this method here or this
‫final loser is executed and empty final losers.
‫So if this should be empty, you should not use it.
‫So only if you have something useful to do in here.
‫You should ever use a file analyzer because otherwise it just uses up performance.
‫So you just have needless loss of performance because when the class contains the file analyzer, an
‫entry is created in the finalizing queue and when if analyzer is then called, the garbage collector
‫is invoked to process that queue.
‫And well, that's why you shouldn't create an empty finalize because it's just going to add something
‫into the queue which is not doing anything and that still reduces performance.
‫All right.
‫So that's generally the file analyzer or the destructor.
‫And in order to test that, it's quite difficult because we if we run out of scope, which in our case
‫is if we run out of the main method, then there's simply not much that we still see because our program
‫simply closes, right?
‫So let's just create a member's object and I'm going to call that number one.
‫It's going to be new members.
‫And this new members or number one is simply going to be our Lucy.
‫So we don't have a constructor where we set the age and the member name and the salary, all those kind
‫of things.
‫Because we keep it simple in this video because it's mainly about the general idea of members and to
‫finalize or the structure.
‫So now let's call number one and let's let her into use or let's call the introducing method.
‫So now she's going to introduce herself and in here we need to give a boolean.
‫So I'm just going to say, okay, I am a friend, so please tell me your salary.
‫So because that's what this introducing method does.
‫And by the way, it's going to call this sharing private info method within the introducing method.
‫So that's the only way around of getting something of a private method outside of that class by calling
‫the private method within a public method.
‫So this sharing private info is a private method.
‫So the access modifier is private, but this public method here can be called from outside, which means
‫it can be called within our program class, for example.
‫And then here, if I try to access that sharing private info, it's going to say members share and private
‫info is inaccessible to due to its protection level.
‫So I just just cannot access it.
‫Now in order to show you this deconstruction of member object.
‫Done.
‫Yeah.
‫This call here, we need to get out of scope.
‫Which means as soon as we close the static void main.
‫So as soon as we get, let's say, to line 18, in my case, that's when the final user is called.
‫So that's when member one is going to be destroyed.
‫If we run that, we will see it for a very, very short second.
‫So let me create it.
‫Actually, it's just going to close directly.
‫So let's write console.log, read key in here.
‫So you see something so that we are my salary is so she.
‫Well, the object is created.
‫She tells us the salary because we are a friend, as we said here.
‫True.
‫And now if I press enter for a split second, you can see that there is some text there.
‫Actually you don't see it.
‫But in the end, after I press the console key, I run into this line here and then the code is executed.
‫So in order to see that we will need to use debug here and we will need to import debug so show potential
‫fixes.
‫All enter use system diagnosis.
‫Are agnostics just going to do that debug thought?
‫And here now I can call something bright.
‫And I just want to write onto this output here and I'm just going to call just that.
‫So deconstruction or destruction because it's destruction of members object.
‫What is happening.
‫So now let's run it again.
‫Actually without the key.
‫We don't need that anymore because we're fine.
‫If the program simply closes afterwards, we're just going to run that.
‫And we see here the structure or destruction of members object.
‫And actually if we get back, we just had their console key.
‫So you can see that it's not executed.
‫So we don't see this information, but only after we press enter that we saw it for a second.
‫Deconstruction of a member object or a member of this object was shown.
‫So that's how you see how structures or file analyzers generally work and what they do.
‫Great.
‫So now you have seen the different types of members.
‫There is a little more to know about members, but just check out the documentation.
‫Then you will see a little more detail what members are and what they do.
‫But for the most part, what we have seen here is going to cover pretty much most of the things that
‫we're going to handle on use in the future.
‫Great.
‫So see you in the next video.