Last section of the studio, so we can go to our last section and we will be studying glass templates
in C++, that's our topic for now.
So what is it template?
That's kind of a difficult question.
Most of the C++ to speed Glanzer these days here in my lecture, I want to keep it more simple, not
sophisticated.
So let's see what is the use of a template.
So in C++, suppose if I want to use a function, write to add two numbers, what will be the possible
thing I can do?
I can create the integer function, write, I can create a function integers like it's an integer function
int some write and I can divide the function and I can add two numbers eight plus B and I can add two
numbers, right?
Suppose if I want to add two floating point numbers, then the same function.
I need to define floor function.
They float some and I need to parse the value of sending the code addition to the values.
So then we introduce a concept card templates.
Our life becomes more easier in the sense, like we will be creating a genetic data, right?
So it's all about genetics.
Sometimes we can't or this stuff s genetics because we are creating a genetic variable Part D so that
genetic variable or genetic type Scarlett and Blade.
And instead of creating different functions for different data, think you may be using a template function
which will actually assign the day by day, according to the name that is really missing?
Suppose if I am calling that template based on chain maxima or something, and I want to add two numbers
man, that'd be no better than numbers.
That'd be floating point at that number.
Then I'd be like integer that I have.
No, I can't have a single function.
And if I'm passing the variables along with the database which they are, my life becomes more easier.
It becomes for me to use a single function to ask those things right.
So here again, see the syntax template.
This is not exactly what by name, but you can use what I wrote a generic name.
You want a name type named Capital X. I name capital by type and name gap.
Is that anything is right here?
Me, we are naming it capital D..
OK, then I'm creating a function.
D. My Emacs.
This will actually compute maximum of two data nodes medium boost and return the maximum value.
So I'm getting tired variable called Xanthi variable for white and this is all genetic data by variable.
I have not used a specific database like integer or Florida debris.
If X is greater than 10x, if BI is greater than my two symbol function.
Now, inside the main function, I have my max function.
I am calling my Emacs function and deciding to compare two numbers of integer type, so I am passing.
This is that syntax using angle bracket.
You have the boss that they Typekit, then you have to open the normal brackets and fosu that values.
So here what going happen?
The campaign internally generates this function where it will make this function going into this function,
or because it's it should be an integer function so it automatically create in my Emacs.
Then it replaces on the daemon, int then in my Macs, then indexing right, then return greater than
white check that will return that value.
Now, when you are using that same function to convert to catechist, this will internally generate
this card becomes like this and it will generate gamma.
Emacs, Gattex and Dowdall then return greater than White X on the right.
Then it will then that higher value.
OK, that's it.
Very similar template.
You only need to i the that it should be first you out to create a genetic template name or type name.
For that you will to use this index.
You can just by heard this index.
Then you again create the function in order to like instead of using that right there that maybe you
can use the bank name over here should be that OK, then this is that a dynamic results would be.
This is the argument.
That's also the one I started.
You can see on here, you can pause the data type and values, then the function will be changed automatically
by the campaign and it will do you that action.
So the are the outlook window function template right now.
OK, let's go to our function template here.
It's very simple.
I have already.
Plot attack, the extreme namespace then created the template type name B B, my Max D X and divided
by next data, and then I'm comparing three different it's my Emacs passing integer.
Then it will create an integer function and three and seven parsing Dobare.
Then it will create that double function instead of using.
These will be replacing with debris everywhere and then characters.
Now let's run this program.
It's very straightforward, so I'm not taking that much time with this lecture.
So how we can bring back G Plus Plus template doc CBB.
OK, I'm not in desktop, see the desktop now again.
C++ template, OK, KB.
Right now, we can run this by it, how we can on this bad Dodge Dart.
Yes.
Comparing the first statement is comparing doing business with owning seven second statements comparing
to integers, but not to bring this back to double dynamic returning the right answer.
Seven.
And that's one which is a great one.
And it's always so it's comparing to Atticus.
I was saying if I was doing this, comparing two characters and pretending that the.