Let's move on to the important topic of kind of tech doesn't distract us.
So can you stick that in C++ is a special function that is automatically called when an object of glass
is created.
So each time when you create that object for a particular class, we will be having a constructor,
which is a special function which is defined inside the class.
That will be the first person to be knocked out of that with the first person which will be caught that,
you know, automatically mean not to call it passively and construct those optional components of a
glass.
So you need to create a conflict that before it will be starting to work so that it would be an noted
before constructor.
But you need to create a sector.
Creating a constructor is very easy.
You need to use the name of that class.
OK, and parentheses class names should be your same class name.
Which class named are going to stick to.
The name of that last name will be used and followed by a parentheses.
You will understand this when you explore the syntax, and constructor will have exact same name of
the class.
When buying, you have to notice and each does not have to return any type at all.
And sector will not be having any return date.
So Constructor is all that function, but it does not have a return date.
So you need not to specify the return date when you create that construct that not even moit return
type is specified in this index.
And constructors can be very useful for setting initial values for certain member variables.
So if you want to set the values of a particular variable, you can use that constructor.
Now, let's go to destructor so distracted.
I'm going to check I'm covering it right away together.
So there is a special member function whenever, like an object is deleted, every memory allocated
for object is deleted when the program is completed.
OK.
So whenever the object is deleted, there will be a destructive.
OK.
Structure will be executed like District 10 will be doing.
It will be just clearing out all the variables clearing the values of that memory.
OK, why we should use destructor the cleanup will be automatically done by that computer when the program
execution is complete.
But if you want to mention something or if you want to do some activities while this cleanup is being
carried out, then we will be using that district.
And how will you get to create a district that?
It's very simple.
It's similar to that of a constructor, but you have to use a little saying this is that D.D.S. while
you will be creating a district, so it will have the same name of the class followed by it.
Before that, it was there will be a TV set, so it's better to see the demo for understanding this
concept.
You will be able to see this by sector and just like that right here.
OK?
We have a constructor program created here and we have class named guide and we have string brand and
string model.
Then we have a kind of set up later here.
This is the constructor.
OK, so constructor, what car constructor knows?
You can see out of here that last name is Scott, and the constructor name is also car constructor is
a function you can see it's having.
It operates right and then it's having it go live in a shopping cart based car.
So this is also a function, but there is no return date, no white noise.
No, and nothing is mentioned out here.
But this current structure and function can access or get three variables X right?
And is it?
And why does a use of the constructor is the variables inside that object?
So we have three variables created inside the car class that is brand model.
And yet and you can supply values that three variables during that creation of the object.
That's why you use it, constructor.
So branding callbacks and modelling all the way on D.N.A. is that x y?
And is that OK?
So what happens?
I'm going to the main function.
I'm creating an object called card object, and God object is passing three values BMW, X5 and one
nine nine nine, right?
How what will happen this when this car object is created?
At first, this constructor will be card and what will happen when this sector will be caught.
It will supply three values already at BMW, X5 and one 1999.
OK.
So it will be coming like this.
X will be equal to BMW X Y.
You will be equal to X Y and Z will be nineteen.
Ninety nine.
OK.
And then X will be supplied to brand and Y will be supplied to model and is then will be supplied to
give off object one.
Similarly, when you create a new object or object to broadly be supplied out to here and will stand
will be supplied out of here and 1969 will be supplied out here.
So for that object, number two brand will become for model, become Mustang and it will become is.
Now you are just printing the value shot object one brand then got up to.
01. model God object rendered here, similarly, we are printing out quite a bit to brand more than
any.
So when I was creating the object for that God Glass two objects, vast object the same, these three
values through this construct.
This is now constructed.
So this constructor is having parameters so some constructors, we can create constructors without parameters
also.
So this constructor cannot accept values from main function when we are creating the object that does
that peculiarity of that parameterized constructor.
So this is a parameterized constructor.
So first of all, let's run this program.
Before that, let me compare it to C++ constructors, not CPB down.
No dog-eared or you can predict output, right?
BMW, X5 1999 and Ford Mustang tendencies in it.
So these values start in object number one, and these values start in object number two.
No wonder that Ex-member is if I don't want to send parameters, I can just go like if I want to set
the values without any parameter, I want to set the values by default.
Then I can use a normal constructor without any parameters.
For that, you just need to replace all these things.
You will just define your ancestor like this and you will put that values here.
Branding or BMW, Mortlake or X5 yet equal to 1990.
But like this, or say you can do what?
I'm not showing that right now, we can just skip it.
So that will be an exercise for my students.
You can just have a look at our constructor without parameter.
OK, now let's go to that destructor park.
So regarding the District of Park, you can see here we have a constructor.
Constructor will not have any design and it will be the same thing, right?
Same last name.
Similarly, Destructor will not have any anything, but it is also having the same class name.
But what is there to differentiate?
There is a delay design.
This is that, as you can see this in your keyboard.
OK, now if I'm creating one object like what happened and sector will be invoked and you can display
again even our same values, or you can display anything inside that kind of sector.
So I'm just displaying object is being created.
That will be the something I'm displaying over here.
You know, when the object is deleted after this object is deleted, one happens after the program is
executed and the lander, all objects will be leading.
So then why not?
Our district every week or so, what I'm doing inside the district, inside the district of I am just
printing an object is being deleted.
That's it.
So when the object is being created, the constructor will execute.
And when the object is deleted, the mistake that we executed and the sticker you can set out to, what
are the things you need you get if you want to see something, you can see that if you want to assign
something to something that can alter you, you can do.
But when the program is being cleaned up, there is no point in us saying something to a right.
It's already getting deleted anyway.
If you want to do something at the end of the program, that's where when you use that this time.
And one more point I want to mention you can define functions with a like if that is a violation or
in a class, and you can in two ways you can define it function inside a glass.
That's some like binary we have missed out.
So if you want to define a function connected to a class name, print hello.
Let me do that here.
It says you can have two ways, so I'm creating a public function by Roy Print.
Hello.
See how creating one way of defining that function for this class line will be you can just write that
definition while you define the class that it's in, say, the class itself.
You can, by the definition of the function, my functions definition, for this example, will be very,
very small.
I'm just printing.
Hello.
OK.
That is my video creating a function inside a class, but that is on another way.
So I know that this OK.
You will not write the definition of the functionality at all.
The definition.
We really need it.
We will be really writing the prototype inside the class.
Then after the class definition is all.
You will be engaged in the definition of the function, but that function will still belong to this
class.
So this is a different way of syntax, OK?
That's only the different syntax, which I'm following.
So how are you going to do that?
You can mention the class name and you can put Scarborough Solution Operator.
Then you can print handle menu again defined that function as you do normally, so it will be SEO.
And so this is one point which we have missed, but I have covered it right now.
So what happens?
This function is still belonging to the class line, but it's defined.
I would say the glass, why we are defining it outside the glass.
It's nothing but simplest explanation is if the function is having the lot of lines, if you define
that function inside the glass itself, it will be a habit.
You will not understand anything where the functions start, where the function and where the glass
started and where the glass ends in order to keep the function.
If the function is very huge and it's having a lot of lines.
It will be always better to follow this approach so that the glass can be light.
You can just look into this glass and you can see the variables and functions in that glass.
If that function is having a lot of explanation.
Lot of lines, this glass will be messed up, right?
So that's why we are using this index to access that.
It was OK.
So that's one point I want to highlight.
So now you have two things to note in our number one is our detector.
And another one is our current helmet.
So I'm just calling in Halo Method at the end of the Line Dog panel discarding and I am running that
program G Plus Plus based dark CPD.
So it's not C++ or.
Both gay types specify for clinicians.
What does that?
Lloyd Brown, hello.
Is it because I put that Boyd out here?
Let's see previous thing, which we have been doing that is a small correction order yet, so you can
see why it should be also prefixed before the glass name, before the car like last name and Scarborough
resolution operator.
Then you have to use that function.
So that's the syntax.
So what will be the return type of this function?
It should be also coming up before the class name.
OK.
Then you need to actually go to the compiler program.
Previously, when we have compiled, we got an error.
So and comparing it now that is an IRA, now you can just bring the date see object is being created.
Land of Line six.
Hello, is this planet?
Because I wanted to show that to you how you can define your function outside of class.
Then it's showing object has been deleted and programs and because object is being deleted, is that
the program is cleaning it now.
That is, that is being executed.
So that's it.
Hope you have.
I'm sure this lecture let me turn to that next one.