OK, so now that we have our basic linked list in this short video, we are going to add a little bit
more functionality.
So this video is just going to be about templating our link list actually, so we can have it hold different
data types.
So let's go ahead and get started.
I'm going to head over to the header file for our node class.
And if you remember from templating part of the course, we are going to start out a same template and
then I might just call this class T pretty standard.
And we are going to have to change this L.A. So it's going to be in L.A. T.
And we will also want to change our node in here to an L.A. T.
This is no longer going to be an integer for a data because it can be different types.
So it's going to be type T.
Same down.
Here are actual member data member here is going to be can type T and this whole node as well.
It's going to need to be declared for as a template as well.
And then so what we're going to do right now.
Is and might remember this from the previous templating videos, but we're going to include the CP file,
actually.
So because of this, we're going to have to actually go in and at our configurations and I'm sorry,
go ahead and edit our R C make build file so we can accommodate for this and add in our templates and
stuff.
We're going to want to remove some stuff from our project so everything compiles.
OK?
All right.
So let's head over to our CP file.
And.
It is working, so this file we are going to see.
We're actually going to comment about this because we do not want a circular include.
So because we included RCMP file in the head of their.
And we are going to I mean, just copy paste this template so we can put it above each of our functions.
So I want to put that here, and this is going to become the tea.
Let's see.
Let's do this here.
I'm actually.
And comment this just for now, but
it turns out no t, we need to change our scope resolution.
You just go ahead and paste this here.
All right, so let's change this to so we're just having to go through and change everything into templated
version, so that returns Typekit instead of it now.
OK.
Let's see if we got that to change that.
And.
I think that should be.
Good.
Let's go back here.
Make sure that we have everything.
And the I'm going to go ahead and comment this out now.
So let's go over to our list here.
And.
For this.
You don't need to put the.
Data type you.
Let's see, we have this.
Change that to do the same thing as well and include our CP file here.
So the last US BP and this is one of several ways to do this.
You can also put the include the header and the CP in the client file.
I command CBP instead of doing this.
But for this, like, we're going to have to remove some things from our project.
They'll stay in the same directory, but we're just going to have to change or see my file or make a
new project from sources and just check those boxes.
And they include certain things in our in our project.
So clients able to compile it OK.
All right, yeah, so I'm just making sure that I want the right stuff here.
I think that.
Tom, this out, and let's just copy paste these guys first.
OK, so.
This we know it's going to have to have.
Type T on it and.
Same here.
This is now passing.
Type T.
This.
We need to.
Change, this is where I actually.
That break point.
And.
Let's see.
I think that should be pretty much.
Everything.
This is red, but hoping things will change once we update our see make file.
OK, so let's head over to our main cup.
Hopefully, these have everything, if not, then I'll be encountering an error that we'll have to fix.
So you might have already seen me miss something and are already on top of it, but let's go ahead and
go back over to Main and add this in here.
So I'm actually going to make a.
Another type.
Oh, yeah, my bad not to acquire those red when I call this on and this is going to be type integer
for one last year, and then I'm going to make another list and it's going to be a cha.
So I'm just going to call this link list to really great of a name.
You know what, actually, let's just call it in English.
And
so now I have two lists.
One is a cha one, two S. And I'm going to change this, the charge taking our data.
And then I'm going to put a little condition down here.
Where if we encounter a sea, it is digit.
Yeah, we encounter something that is a digit.
We will.
Copy this.
We will append the data in a minute minus subtract the cha zero just for ASCII purposes because we're
going to want to change that cha into an end.
And so I'm going to want what the same number that's appearing is the charm, but I'm going to want
to actual integers.
So this is a nice kind of basic way to do that.
And
otherwise, I'm just going to append it to the linked list char.
And it's going to be in it normally because I'm taking in a char is the data now and we will print that
first list and then we will print the second list.
And so because I did that, I'm going to go into our input file and I'm just going to do a b c d e f
g.
So one two three four five six seven a b c d e f g.
And.
Me see if I need anything else here.
I think we should begin to go.
And so what I'm going to have to do is we're we're going to need to go into this see make lists file.
And we are actually we just need to actually take out.
These
CBP files, so we could take them all out, actually.
It's kind of pointless to have the headers.
In there, but.
Yeah, I'll just take those out.
I'm going to reload the changes.
And go ahead and run this and see if it works, and so if everything is correct, we should get what
we see down here, as well as a lengthy list of chores.
OK, so we have a problem already here, did not could
not put that there.
OK, let's try that again.
OK.
Nice.
So.
It's like we have both of those.
All right, so this is just us prepping actually for.
A few coding assignments where we're actually going to start turning this into a doubling length list
and then we're going to have to look at inserting into these lists and a few problems algorithms to
go through this list and do some different things.
But today it was just about or this video was just about template in our link list so we can take in
multiple types.
So now you could do an object or whatever you want.
And I'm sure you're somewhat familiar with the templates by now, but it is important to template some
of your data structures so I can give you that additional functionality.
All right.
See you in the next lecture.